home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / castools.zip / TKMANUAL.TXT < prev    next >
Text File  |  1990-03-13  |  195KB  |  8,449 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.                    Programmer's Toolkit for CAS and the Phonebook
  22.  
  23.  
  24.  
  25.                                     Version 1.0B
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.                Copyright π 1990.  All rights reserved.
  49.  
  50.                Intel Corporation
  51.                5200 N.E. Elam Young Pkwy.
  52.                Hillsboro, OR 97124-6497
  53.  
  54.                Intel Part Number:  302638-001A
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.                Intel Corporation developed this Toolkit.  Although this
  75.                Toolkit has been released into the public domain and is not
  76.                confidential or proprietary, it is still the copyright and
  77.                property of Intel Corporation.
  78.  
  79.  
  80.           DISCLAIMER OF WARRANTY
  81.  
  82.                INTEL CORPORATION EXCLUDES ANY AND ALL IMPLIED WARRANTIES,
  83.                INCLUDING WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  84.                PARTICULAR PURPOSE.  INTEL DOES NOT MAKE ANY WARRANTY OF
  85.                REPRESENTATION, EITHER EXPRESSED OR IMPLIED, WITH RESPECT TO
  86.                THIS TOOLKIT, ITS QUALITY, PERFORMANCE, MERCHANTABILITY, OR
  87.                FITNESS FOR A PARTICULAR PURPOSE.  INTEL SHALL NOT HAVE ANY
  88.                LIABILITY FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  89.                ARISING OUT OF OR RESULTING FROM THE USE OR MODIFICATION OF
  90.                THIS TOOLKIT.
  91.  
  92.  
  93.  
  94.                This manual uses the following trademarks:
  95.  
  96.                Connection CoProcessor is a
  97.                trademark and Intel is a
  98.                registered trademark of Intel
  99.                Corporation.
  100.  
  101.                Other brand and product names
  102.                are trademarks of their
  103.                respective owners.
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.           TABLE OF CONTENTS
  142.  
  143.  
  144.  
  145.  
  146.           1   ABOUT THIS MANUAL
  147.                How To Use This Manual  ..............................   1-1
  148.                Conventions  .........................................   1-2
  149.  
  150.  
  151.  
  152.           2   GETTING STARTED
  153.                Toolkit Requirements  ................................   2-1
  154.                What's On The Diskette?  .............................   2-2
  155.                Which Library To Use  ................................   2-3
  156.                Installing The Toolkit  ..............................   2-5
  157.                Modifying The Libraries  .............................   2-5
  158.  
  159.  
  160.  
  161.           3   OVERVIEW OF CAS AND THE TOOLKIT
  162.                Resident Manager  ....................................   3-1
  163.                Queues and Events  ...................................   3-1
  164.                Control Files and File Transfer Records (FTRs)  ......   3-2
  165.                Event Handles  .......................................   3-3
  166.                Toolkit Data Structures and Error Handling  ..........   3-3
  167.                  The Include Files  .................................   3-3
  168.                  CAS Structures  ....................................   3-4
  169.                  Additional Structures  .............................   3-5
  170.                  Error Handling  ....................................   3-5
  171.                Memory Allocation  ...................................   3-6
  172.  
  173.  
  174.  
  175.           4   CASLIB:  C LIBRARY FOR CAS
  176.  
  177.               DEVELOPERS
  178.                Compiling and Linking With CASLIB  ...................   4-1
  179.                CASLIB Functions Grouped by Operation  ...............   4-2
  180.                  Configuration  .....................................   4-2
  181.                  Event and Queue Queries  ...........................   4-2
  182.                  Event Creation  ....................................   4-3
  183.                  Event Manipulation  ................................   4-3
  184.                  File Management  ...................................   4-3
  185.                CASAbortCurrentEvent (02H)  ..........................   4-4
  186.                CASAutoReceiveState (0FH)  ...........................   4-6
  187.                CASDeleteAllFiles (09H)  .............................   4-8
  188.                CASDeleteFile (08H)  .................................  4 10
  189.                CASFindFirst (05H)  ..................................  4-12
  190.                CASFindNext (06H)  ...................................  4-14
  191.                CASGetCurrentEventStatus (10H)  ......................  4-16
  192.                CASGetEventDate (0AH)  ...............................  4-18
  193.  
  194.  
  195.  
  196.                                                                         iii
  197.           iii                                                              
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.                CASGetEventTime (0CH)  ...............................  4-20
  206.                CASGetExternalData (0EH)  ............................  4-22
  207.                CASGetHardwareStatus (12H)  ..........................  4-23
  208.                CASGetInstalledState (05H)  ..........................  4-25
  209.                CASGetQueueStatus (11H)  .............................  4-27
  210.                CASMoveReceivedFile (14H)  ...........................  4-29
  211.                CASOpenFile (07H)  ...................................  4-31
  212.                CASRunDiagnostics (13H)  .............................  4-33
  213.                CASSetTaskDate (0BH)  ................................  4-35
  214.                CASSetTaskTime (0DH)  ................................  4-37
  215.                CASSubmitSingleFile (15H)  ...........................  4-39
  216.                CASSubmitTask (01H)  .................................  4-41
  217.                CASUnloadResidentManager (16H)  ......................  4-43
  218.  
  219.  
  220.  
  221.           5   FAXLIB:  HIGH-LEVEL LIBRARY FOR CAS
  222.  
  223.               DEVELOPERS
  224.                Compiling and Linking With FAXLIB  ...................   5-1
  225.                FAXLIB Functions Grouped by Operation  ...............   5-2
  226.                  Event Management  ..................................   5-2
  227.                  Event and Queue Queries  ...........................   5-3
  228.                  Error Handling  ....................................   5-3
  229.                FAXCancelTask  .......................................   5-4
  230.                FAXCopyECS  ..........................................   5-6
  231.                FAXError  ............................................   5-8
  232.                FAXFreeECS  ..........................................  5-11
  233.                FAXGetEventControlInfo  ..............................  5-13
  234.                FAXGetEventCover  ....................................  5-16
  235.                FAXGetEventFileInfo  .................................  5-19
  236.                FAXSend  .............................................  5-22
  237.                FAXSubmitTask  .......................................  5-25
  238.  
  239.  
  240.  
  241.           6   PBLIB:  LIBRARY FOR PHONEBOOK
  242.  
  243.               MANAGEMENT
  244.                Compiling and Linking With PBLIB  ....................   6-2
  245.                Phonebook Functions Grouped by Operation  ............   6-2
  246.                  General Management  ................................   6-2
  247.                  Entry Queries  .....................................   6-3
  248.                  Entry Modification  ................................   6-3
  249.                Phonebook Buffering...................................   6-3
  250.                PbAddEntry  ..........................................   6-4
  251.                PbAddToGroup..........................................   6-7
  252.                PbBufferOffsets  .....................................  6-10
  253.                PbCreatePhonebook  ...................................  6-13
  254.                PbFindFirstOrNext  ...................................  6-15
  255.                PbFreePBE  ...........................................  6-18
  256.                PbGarbageCollect  ....................................  6-20
  257.                PbGetEntry  ..........................................  6-22
  258.                PbLookUpSendInfo  ....................................  6-25
  259.  
  260.  
  261.  
  262.           iv                                                               
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.                PbModifyEntry  .......................................  6-28
  272.                PbOpenPhonebook  .....................................  6-31
  273.                PbRemoveEntry  .......................................  6-33
  274.                PbRemoveFromGroup  ...................................  6-36
  275.  
  276.  
  277.  
  278.           A   TOOLKIT COMPATIBILITY WITH TURBO C
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.                                                                           v
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.                ABOUT THIS MANUAL
  339.  
  340.           1    
  341.  
  342.                This manual, which accompanies your diskette, describes the
  343.                Programmer's Toolkit for CAS and the Phonebook.  This
  344.                chapter presents an overview of the manual's contents and
  345.                describes the conventions used.
  346.  
  347.  
  348.  
  349.           How To Use This Manual
  350.                This manual explains the features and operation of the
  351.                Toolkit libraries.  Once you are familiar with the libraries
  352.                and how to use them, you can use this manual as a quick
  353.                reference for function names, parameters, and return values.
  354.  
  355.                Chapter 1.  About This Manual
  356.  
  357.                This chapter presents an overview of the manual's contents
  358.                and describes the conventions used.
  359.  
  360.                Chapter 2.  Getting Started
  361.  
  362.                This chapter introduces you to the Toolkit and discusses
  363.                information that you will need to use the Toolkit.  Read
  364.                this chapter before you try to install the Toolkit.
  365.  
  366.                Chapter 3.  Overview of CAS and the Toolkit
  367.  
  368.                This chapter discusses CAS and the Toolkit and explains the
  369.                Toolkit components.  This chapter, while valuable to all
  370.                users, is directed to less experienced CAS developers.
  371.  
  372.                Chapter 4.  CASLIB:  C Library For CAS Developers
  373.  
  374.                This chapter describes the CASLIB library.  This library
  375.                contains the low-level functions that perform the services
  376.                of the CAS 1.0B function set.  Chapter 4 also describes how
  377.                to compile and link with CASLIB.  The last section describes
  378.                each of the CASLIB functions in detail.
  379.  
  380.                Chapter 5.  FAXLIB:  High-Level Library For CAS Developers
  381.  
  382.                This chapter describes the FAXLIB library for CAS
  383.                developers.  The FAXLIB Library contains the high-level
  384.                functions that provide simplified management of events and
  385.                error handling.  This chapter also describes how to compile
  386.                and link with FAXLIB.  The last section describes each of
  387.                the FAXLIB functions in detail.
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.           About This Manual                                             1-1
  395.           1-1                                             About This Manual
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.                Chapter 6.  PBLIB:  Library for Phonebook Management
  404.  
  405.                This chapter describes the PBLIB library for phonebook
  406.                management.  The phonebook is a database that CAS
  407.                applications might use to make task generation easier for
  408.                end-users.  This chapter also describes how to compile and
  409.                link with PBLIB.  The last section describes each of the
  410.                PBLIB functions in detail.
  411.  
  412.                Appendix A.  Toolkit Compatibility With Turbo C
  413.  
  414.                This appendix provides information on using Turbo C with the
  415.                Toolkit.
  416.  
  417.  
  418.  
  419.           Conventions
  420.                In this manual, the parameters and variables for each
  421.                library are shown in italics.  This manual also uses the
  422.                following convention.
  423.  
  424.  
  425.  
  426.                NOTE:
  427.                     Indicates important information about how something
  428.                     works or how you should do something.
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.           1-2                                             About This Manual
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.                GETTING STARTED
  471.  
  472.           2    
  473.  
  474.                The Toolkit is a library of functions that provides C
  475.                programmers with a convenient interface to both the
  476.                DCA/Intel Communicating Applications Specification (CAS)
  477.                Version 1.0B and the Phonebook.  The Toolkit gives C
  478.                developers an efficient way to build communications into
  479.                their application programs.
  480.  
  481.                This chapter introduces you to the Toolkit and discusses the
  482.                following topics:
  483.  
  484.                ╖ Toolkit Requirements
  485.                ╖ What's on the Diskette
  486.                ╖ Which Library to Use
  487.                ╖ Installing the Toolkit
  488.                ╖ Modifying the Libraries.
  489.  
  490.                For a discussion on the concepts and terminology that apply
  491.                to CAS and the Toolkit, refer to Chapter 3.
  492.  
  493.  
  494.  
  495.           Toolkit Requirements
  496.                The Toolkit system requirements are determined by the CAS-
  497.                supported hardware (such as Intel's Connection CoProcessor)
  498.                that you are using.
  499.  
  500.                To use the Toolkit libraries, you need the following
  501.                software:
  502.  
  503.                ╖ DOS 3.0 or higher
  504.                ╖ Microsoft C 5.1 or higher
  505.  
  506.                You can also use Borland's Turbo C.  For information on
  507.                using Turbo C with the Toolkit, see Appendix A.
  508.  
  509.                The Toolkit libraries use no graphic video modes, nor do
  510.                they use a mouse.
  511.  
  512.  
  513.  
  514.                NOTE:
  515.                     Intel requires users of the Programmer's Toolkit for
  516.                     CAS and the Phonebook to have access to a copy of the
  517.                     DCA/Intel Communicating Applications Specification for
  518.                     additional information.
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.           Getting Started                                               2-1
  527.           2-1                                               Getting Started
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.           What's On The Diskette?
  537.                The root directory of the Toolkit diskette has the following
  538.                six directories:
  539.  
  540.                ╖ INCLUDE
  541.                ╖ LIB
  542.                ╖ CASSRC
  543.                ╖ FAXSRC
  544.                ╖ PBSRC
  545.                ╖ MANUAL
  546.  
  547.                The INCLUDE directory contains all the include files (*.H
  548.                and *.INC) that are used by the libraries and programs that
  549.                use the libraries.  These files are:
  550.  
  551.                ╖ CAS.H
  552.                ╖ FAX.H
  553.                ╖ FAXGLOB.H
  554.                ╖ FAXDFLTS.H
  555.                ╖ FAXERROR.H
  556.                ╖ PHONEBK.H
  557.                ╖ PBGLOBAL.H
  558.                ╖ PBDFLT.H
  559.                ╖ PBERROR.H
  560.                ╖ MULTI.INC
  561.                ╖ MODEL.INC
  562.  
  563.                The LIB directory contains four memory-model versions
  564.                (SMALL, MEDIUM, COMPACT, and LARGE) for each of the three
  565.                libraries of the Toolkit.  The libraries were compiled and
  566.                built by Microsoft C 5.1.
  567.  
  568.                The CASLIB files are:
  569.  
  570.                ╖ SCASLIB.LIB
  571.                ╖ MCASLIB.LIB
  572.                ╖ CCASLIB.LIB
  573.                ╖ LCASLIB.LIB
  574.  
  575.                The FAXLIB files are:
  576.  
  577.                ╖ SFAXLIB.LIB
  578.                ╖ MFAXLIB.LIB
  579.                ╖ CFAXLIB.LIB
  580.                ╖ LFAXLIB.LIB
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.           2-2                                               Getting Started
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.                The PBLIB files are:
  602.  
  603.                ╖ SPBLIB.LIB
  604.                ╖ MPBLIB.LIB
  605.                ╖ CPBLIB.LIB
  606.                ╖ LPBLIB.LIB
  607.  
  608.                The three SRC directories contain the source files for the
  609.                functions in the three Toolkit libraries.  They also contain
  610.                sample make files and batch files for building the libraries
  611.                using Microsoft C 5.1.
  612.  
  613.                The MANUAL directory contains two files: an ASCII version of
  614.                this manual and an ASCII version of Recent News About the
  615.                CAS and Phonebook Toolkit.
  616.  
  617.                ╖ TKMANUAL.TXT
  618.                ╖ NEWS.TXT
  619.  
  620.                In addition to the six directories, the root directory
  621.                contains the following two files:
  622.  
  623.                ╖ README
  624.                ╖ WHATSOND.ISK
  625.  
  626.  
  627.  
  628.           Which Library To Use
  629.                The Toolkit consists of three libraries of functions.  These
  630.                are as follows:
  631.  
  632.                CASLIB         contains the low-level functions that perform
  633.                               the services of the CAS function set.
  634.  
  635.                FAXLIB         contains the high-level functions that
  636.                               provide simplified management of
  637.                               communications tasks and error handling.
  638.  
  639.                PBLIB          contains the phonebook functions which
  640.                               provide an interface to the Intel phonebooks.
  641.  
  642.  
  643.  
  644.                NOTE:
  645.                     The FAXLIB functions use some functions from CASLIB.
  646.                     If you use FAXLIB functions, your application must be
  647.                     linked to both the FAXLIB and CASLIB libraries.
  648.  
  649.                Because the CASLIB is a one-to-one mapping of C functions to
  650.                the assembly-level CAS functions, C applications already
  651.                written to the CAS functions can be made more compact and
  652.                maintainable by converting CAS calls to CASLIB function
  653.                calls.
  654.  
  655.  
  656.  
  657.  
  658.           Getting Started                                               2-3
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.                New CAS applications can benefit from using the CASLIB and
  668.                FAXLIB functions in combination.  A time performance gain
  669.                results from using the CASLIB functions exclusively, but the
  670.                FAXLIB functions require less application code.  Refer to
  671.                the following two code examples which submit the same Send
  672.                event.  The first example uses the low-level CASSubmitTask
  673.                function.
  674.  
  675.  
  676.  
  677.                NOTE:
  678.                     For information on "Send events," refer to Chapter 3 of
  679.                     this manual.
  680.  
  681.                  int event_hdl;
  682.                  FILE *fptr;
  683.                  ECF *ecf;
  684.                  FTR *ftr;
  685.  
  686.                  ecf = (ECF *)calloc(1, sizeof(ECF));
  687.                  ftr = (FTR *)calloc(1, sizeof(FTR));
  688.                  ecf->FileCount = 1;
  689.                  ecf->FTROffset = 383;
  690.                  strcpy(ecf->DestinationName, "lab fax");
  691.                  strcpy(ecf->Phone, "9, 645-8468");
  692.  
  693.                  strcpy(ftr->FileName, "c:\\autoexec.bat");
  694.  
  695.                  fptr = fopen("c:\\sample.ecf", "wb");
  696.                  fwrite(ecf, sizeof(ECF), 1, fptr);
  697.                  fwrite(ftr, sizeof(FTR), 1, fptr);
  698.                  fclose(fptr);
  699.                  free(ecf);
  700.                  free(ftr);
  701.                  event_hdl = CASSubmitTask("c:\\sample.ecf");
  702.  
  703.  
  704.                The second example uses the high-level FAXSend function.
  705.  
  706.                  FILELIST file1 = {"c:\\autoexec.bat",
  707.                                    ASCII,
  708.                                    NULL};
  709.  
  710.                  int retval;
  711.  
  712.                  retval = FAXSend("lab fax", "9, 645-8468", &file1,
  713.                                   &NULL, &NULL);
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.           2-4                                               Getting Started
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.                The PBLIB functions manage the phonebook files; they do not
  734.                perform any communications activity or interface with the
  735.                Resident Manager or the fax board.  While the Intel
  736.                phonebook format is described in the DCA/Intel Communicating
  737.                Applications Specification, it is not officially part of the
  738.                specification.  The Intel phonebook format is compatible
  739.                with Intel's application software.  It may or may not be
  740.                compatible with phonebook formats used by other CAS
  741.                compatible boards.  PBLIB uses the Intel phonebook format
  742.                described in the DCA/Intel Communicating Applications
  743.                Specification.
  744.  
  745.  
  746.  
  747.                NOTE:
  748.                     Be advised that using PBLIB may result in creating
  749.                     phonebooks that are compatible only with Intel
  750.                     phonebooks.
  751.  
  752.  
  753.  
  754.           Installing The Toolkit
  755.                To install the files needed to link an application to one or
  756.                more of the Toolkit libraries, do the following:
  757.  
  758.                1.   Switch to your application subdirectory (for example,
  759.                     \APP\SOURCE) on the hard disk as follows:
  760.  
  761.                     C>CD \APP\SOURCE
  762.  
  763.                2.   Copy the Include files:
  764.  
  765.                     C>COPY A:\INCLUDE\*.*
  766.  
  767.                3.   Copy the libraries with the following command:
  768.  
  769.                     C>COPY A:\LIB\*.*
  770.  
  771.                Refer to the appropriate chapter for each library for
  772.                information on linking applications.  For additional
  773.                information on the structure of the Toolkit, refer to the
  774.                README file in the root directory of the Intel diskette.
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.           Getting Started                                               2-5
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.  
  800.           Modifying The Libraries
  801.                To modify and rebuild the FAXLIB and PBLIB libraries, you
  802.                need Microsoft C version 5.1 or later.  The CASLIB functions
  803.                are C function versions of the CAS functions and are a
  804.                public standard.  You probably should not modify them.  If
  805.                you do modify these functions, you need Microsoft Macro
  806.                Assembler version 5.1 or later.  Make files, batch files,
  807.                and READ.ME files with directions for building the three
  808.                libraries are in the SRC directories of the CAS and
  809.                Phonebook Toolkit diskette.
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.           2-6                                               Getting Started
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.                The source files for the libraries are in the following
  866.                subdirectories:
  867.  
  868.                ╖ For CASLIB: \CASSRC
  869.                ╖ For FAXLIB: \FAXSRC
  870.                ╖ For PBLIB: \PBSRC
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.           Getting Started                                               2-7
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932.                OVERVIEW OF CAS AND THE TOOLKIT
  933.  
  934.           3    
  935.  
  936.                This chapter provides an overview of the DCA/Intel
  937.                Communicating Applications Specification (CAS) Version 1.0B
  938.                and the Toolkit.  All users will profit from reading this
  939.                chapter but it is directed specifically to new CAS
  940.                developers.  The information in this chapter provides you
  941.                with a background in the basic components and terminology
  942.                that apply to CAS and the Toolkit.  For additional
  943.                information on the components presented here, refer to the
  944.                individual reference page for the appropriate function or
  945.                refer to the DCA/Intel Communicating Applications
  946.                Specification.
  947.  
  948.                This chapter discusses the following components of the
  949.                Programmer's Toolkit for CAS and the Phonebook:
  950.  
  951.                ╖ Resident Manager
  952.                ╖ Queues and Events
  953.                ╖ Control Files
  954.                ╖ File Transfer Records (FTRs)
  955.                ╖ Event Handles
  956.                ╖ Toolkit Data Structures
  957.                ╖ Error Handling
  958.  
  959.  
  960.  
  961.           Resident Manager
  962.                The Resident Manager is software that manages CAS events and
  963.                takes care of CAS internal housekeeping.  For example, the
  964.                Resident Manager takes information to be sent from the
  965.                application and sends it.  When receiving information, the
  966.                Resident Manager stores the information and makes it
  967.                available to the application.  The Resident Manager provides
  968.                these services and, as a result, the developer does not have
  969.                to monitor events.
  970.  
  971.                The following sections define CAS events and describe how
  972.                the Resident Manager monitors them.
  973.  
  974.  
  975.  
  976.           Queues and Events
  977.                The Resident Manager maintains the following three queues
  978.                internally.  Each queue consists of zero or more individual
  979.                events.
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.           Overview of CAS and the Toolkit                               3-1
  989.           3-1                               Overview of CAS and the Toolkit
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.                  Task Queue     is a list of pending send events.  A Send
  998.                                 event occurs when a local computer
  999.                                 transmits information to a remote computer
  1000.                                 or a fax machine.  The application
  1001.                                 developer initiates a Send event.
  1002.  
  1003.                  Receive Queue  is a list of the received events.  A
  1004.                                 Receive event occurs when the local
  1005.                                 computer receives information from a remote
  1006.                                 computer or a fax machine.  An external
  1007.                                 activity, e.g., a remote computer call
  1008.                                 initiates a Receive event.
  1009.  
  1010.                  Log Queue      is a record of send and receive events.
  1011.                                 The local computer records the details of a
  1012.                                 successful or unsuccessful communication
  1013.                                 activity.  The Resident Manager generates a
  1014.                                 Log automatically when a Send event or a
  1015.                                 Receive event occurs.
  1016.  
  1017.  
  1018.  
  1019.           Control Files and File Transfer Records (FTRs)
  1020.                A Control File contains the specific control information
  1021.                (who to call, when to call, etc.) for a given Send or
  1022.                Receive event.  For example, the Control File for a Send
  1023.                event contains the phone number, date, and time information
  1024.                for that event.
  1025.  
  1026.                The File Transfer Record (FTR) is a data structure that is a
  1027.                component of the Control File.  It contains specific
  1028.                information about the file to be sent (file name, file type,
  1029.                etc.).  There is one FTR for each file sent.  For example,
  1030.                if developers want to send two files to a remote computer,
  1031.                they need to complete one Control File and two FTR(s).  The
  1032.                exact formats for both the Control File and the FTR can be
  1033.                found in the DCA/Intel Communicating Applications
  1034.                Specification.
  1035.  
  1036.  
  1037.           Control Files for Send Events
  1038.                While Send events are pending, the Resident Manager keeps
  1039.                the Control Files in the Task Queue.  Once a Send event is
  1040.                completed, successfully or not, the Resident Manager keeps
  1041.                the Control File in Log Queue.
  1042.  
  1043.  
  1044.           Current Events
  1045.                When the hardware is sending or receiving an event, that
  1046.                event is current.  Applications can access information on a
  1047.                current event only by using the function
  1048.                CASGetCurrentEventStatus.
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.           3-2                               Overview of CAS and the Toolkit
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.           Control Files for Receive Events
  1064.                While Receive events are being received, they are current
  1065.                events.  Once a Receive event is completed, the Resident
  1066.                Manager creates and places a Control File for it in both the
  1067.                Receive and the Log queues. The Control File in the Log
  1068.                Queue is a copy of the Control File in the Receive Queue.
  1069.  
  1070.  
  1071.  
  1072.           Event Handles
  1073.                Each event is associated with a unique, non-zero positive
  1074.                integer called an event handle.  All the Toolkit functions
  1075.                that submit events return this handle if they are
  1076.                successful.  The Toolkit functions that find events use this
  1077.                number as their search key.  This number stays the same when
  1078.                the event changes queues, between invocations of the
  1079.                application, even when the computer is turned off and on
  1080.                again.
  1081.  
  1082.  
  1083.  
  1084.           Toolkit Data Structures and Error Handling
  1085.                The following sections briefly discuss the Toolkit design.
  1086.                For additional information, read the DCA/Intel Communicating
  1087.                Applications Specification or the commented include files
  1088.                that are provided with the Toolkit.
  1089.  
  1090.  
  1091.           The Include Files
  1092.                The include files provided with the Toolkit are:
  1093.  
  1094.                  CAS.H          defines CAS data types, constants,
  1095.                                 structures, and function prototypes for
  1096.                                 CASLIB functions.  Include this file for
  1097.                                 applications that use the CASLIB or FAXLIB
  1098.                                 functions.
  1099.  
  1100.                  FAX.H          defines structures, constants, and function
  1101.                                 prototypes for FAXLIB functions.  Include
  1102.                                 this file for applications that use the
  1103.                                 FAXLIB functions.
  1104.  
  1105.                  FAXGLOB.H      defines the global error number variables
  1106.                                 FAXerrno and CASerrorcode.  Include this
  1107.                                 file for applications that use FAXLIB
  1108.                                 functions.
  1109.  
  1110.                  FAXDFLTS.H     defines and initializes default FTR and
  1111.                                 Event Control structures.  Include this
  1112.                                 file for applications that use either
  1113.                                 FAXSend or FAXSubmitTask.
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.           Overview of CAS and the Toolkit                               3-3
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.                  FAXERROR.H     defines and initializes the global error
  1130.                                 message tables FAXerrlist and CASerrors.
  1131.                                 Include this file for applications that use
  1132.                                 FAXError.
  1133.  
  1134.                  PHONEBK.H      defines data types, constants, structures,
  1135.                                 and function prototypes for functions in
  1136.                                 PBLIB.  Include this file for applications
  1137.                                 that use the PBLIB functions.
  1138.  
  1139.                  PBGLOBAL.H     defines the global error number variable
  1140.                                 Pberrno.  Included this file for
  1141.                                 applications that use the PBLIB functions.
  1142.  
  1143.                  PBDFLT.H       defines and initializes the default
  1144.                                 phonebook header structure used by the
  1145.                                 PBLIB function PbCreatePhonebook.  Include
  1146.                                 this file for applications that use
  1147.                                 PbCreatePhonebook.
  1148.  
  1149.                  PBERROR.H      defines and initializes the global message
  1150.                                 table, Pberrlist.  Include this file for
  1151.                                 applications that use this table.
  1152.  
  1153.  
  1154.           CAS Structures
  1155.                The contents of Control Files and other data structures used
  1156.                by the Resident Manager are specified in the DCA/Intel
  1157.                Communicating Applications Specification by bit field.  To
  1158.                make programming to CAS easier for application developers
  1159.                using high-level languages like C, Intel has developed
  1160.                structures in the Toolkit that follow those bit-field
  1161.                specifications.  The Toolkit structures are:
  1162.  
  1163.                Toolkit Structure Name                                   CAS Name
  1164.  
  1165.                ECF                 Control File.
  1166.  
  1167.                FTR                 File Transfer Record.
  1168.  
  1169.                EDB                 External Data Block, defined under
  1170.                                    CASGetExternalData.
  1171.  
  1172.                SFTR                The data area defined under the
  1173.                                    CASSubmitSingleFile.
  1174.  
  1175.                CECS                The subset of the Task Control File
  1176.                                    defined under CASGetCurrentEventStatus.
  1177.  
  1178.                HWSTAT              Hardware status data, returned by
  1179.                                    CASGetHardwareStatus.
  1180.  
  1181.                PCXFILE             Header of a PCX graphic file.
  1182.  
  1183.  
  1184.  
  1185.  
  1186.           3-4                               Overview of CAS and the Toolkit
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.                DCXFILE             Header of a DCX graphic file.
  1196.  
  1197.                QSTAT               Queue status returned by
  1198.                                    CASGetQueueStatus.
  1199.  
  1200.                CAS_DATE            Year, month, and day, used by
  1201.                                    CASGetEventDate and CASSetTaskDate to
  1202.                                    get and set an event's date.
  1203.  
  1204.                CAS_TIME            Hour, minute, and second, used by
  1205.                                    CASGetEventTime and CASSetTaskTime, to
  1206.                                    get and set an event's time.
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.           Overview of CAS and the Toolkit                               3-5
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261.           Additional Structures
  1262.                Besides the structures that are defined in CAS, the Toolkit
  1263.                uses additional structures for managing the fax and file
  1264.                transfer events.
  1265.  
  1266.                ErrorTable     For mapping CAS error codes to message
  1267.                               strings and error classes.
  1268.  
  1269.                FTRLIST        Linked list of FTRs.
  1270.  
  1271.                FILELIST       Linked list of filenames and file types.
  1272.  
  1273.                ECS            Event Control Structure.  Includes the
  1274.                               Control File, the cover text, and the
  1275.                               FTRLIST.
  1276.  
  1277.  
  1278.           Error Handling
  1279.                The CASLIB functions return negative CAS error codes as
  1280.                described in the DCA/Intel Communicating Applications
  1281.                Specification.
  1282.  
  1283.                The FAXLIB functions provide additional error handling
  1284.                support through two global error variables and two error
  1285.                message tables.  The global error variables are FAXerrno and
  1286.                CASerrorcode defined in the file FAXGLOB.H.  The error
  1287.                message tables are FAXerrlist and CASerrors, defined in the
  1288.                file FAXERROR.H.
  1289.  
  1290.                When FAXLIB functions encounter error conditions or
  1291.                warnings, they set the global variable FAXerrno to a
  1292.                positive non-zero value.  If FAXerrno is set to a positive
  1293.                value, it indexes the message table FAXerrlist.  To retrieve
  1294.                error and warning information from FAXLIB function calls,
  1295.                applications must include the file FAXERROR.H, test FAXerrno
  1296.                after each call, and if it's non-zero, look up the message
  1297.                in FAXerrlist.
  1298.  
  1299.                The FAXLIB function FAXError uses these global variables and
  1300.                message tables to find and return error messages to
  1301.                applications using either FAXLIB or CASLIB functions.  For
  1302.                information on how to use FAXError, refer to the reference
  1303.                page for that function.
  1304.  
  1305.                All the FAXLIB functions return 0 (NULL or FAIL) to indicate
  1306.                an error, so testing both FAXerrno and the return value
  1307.                determines whether an error or warning has occurred.
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.           3-6                               Overview of CAS and the Toolkit
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.                When PBLIB functions encounter error conditions, they set
  1328.                the global variable Pberrno to a positive non-zero value.
  1329.                Applications that want to use Pberrno to obtain information
  1330.                about errors should include the file PBERROR.H and use
  1331.                Pberrno as an index to the table of error messages in
  1332.                PBerrlist.  If the applications succeed without error or
  1333.                warning, they set Pberrno to zero.
  1334.  
  1335.                All PBLIB functions except PbFreePBE return 0 (NULL or FAIL)
  1336.                to indicate an error, so testing both Pberrno and the return
  1337.                value determines whether an error or warning has occurred.
  1338.  
  1339.  
  1340.           Memory Allocation
  1341.                The FAXLIB and PBLIB functions provide two ways to handle
  1342.                memory allocation.  Either the application provides all the
  1343.                memory for the data structures or the function allocates the
  1344.                memory, using the malloc C Library function.  Applications
  1345.                can choose to manage memory or let the Toolkit manage
  1346.                memory.  This flexibility allows applications to use
  1347.                expanded memory if it is available.
  1348.  
  1349.                When a function returns a substantial or potentially
  1350.                substantial amount of data, it takes as one of its
  1351.                parameters a pointer to a structure to hold that data.  The
  1352.                return value is also a pointer to the data returned.  If the
  1353.                application provides all the memory itself, it passes a
  1354.                valid pointer to the memory space.  The function uses the
  1355.                memory space for the data returned and returns the same
  1356.                pointer.  If the application has the Toolkit function
  1357.                allocate the memory, the application passes NULL as that
  1358.                pointer parameter.  Then the Toolkit function allocates the
  1359.                memory it needs, fills that memory with the data, and
  1360.                returns the pointer to the memory allocated.
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.           Overview of CAS and the Toolkit                               3-7
  1385.  
  1386.  
  1387.  
  1388.  
  1389.      CASLIB:  C LIBRARY
  1390.  
  1391. 4    FOR CAS DEVELOPERS
  1392.      The CASLIB functions provide a one-to-one mapping of C language
  1393.      functions to the assembly-level functions defined in CAS 1.0B.  To
  1394.      provide greater efficiency and a broader base of compatible compilers,
  1395.      all CASLIB functions use the Pascal calling convention.  CAS data
  1396.      structures are provided in the form of C structures and are defined in
  1397.      the file CAS.H.
  1398.  
  1399.      This chapter describes each function listed in alphabetical order.
  1400.      The format of the function descriptions is as follows:
  1401.  
  1402.      ╖ Description of the function.
  1403.  
  1404.      ╖ Summary provides the syntax for each function.
  1405.  
  1406.      ╖ Parameters describes the parameters for each function.
  1407.  
  1408.      ╖ Return Value can be used to test for error conditions or to provide
  1409.        the requested information.
  1410.  
  1411.      ╖ Remarks provides additional information on the function.
  1412.  
  1413.      ╖ See Also lists related functions.
  1414.  
  1415.      ╖ Example Program shows how the function is used.
  1416.  
  1417.  
  1418.  
  1419. Compiling and Linking With CASLIB
  1420.      To use functions from the CASLIB library, applications must include
  1421.      the file CAS.H and link to the correct library for the memory model
  1422.      they are using.  For example, the following commands are the compile
  1423.      and link commands for an application called SAMPLE.C written for the
  1424.      small memory model.
  1425.  
  1426.      cl /c /AS sample.c
  1427.      link sample ,, NUL, SCASLIB;
  1428.  
  1429.      To use CL.EXE to both compile and link, type the following command:
  1430.  
  1431.      cl /AS sample.c /l SCASLIB
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450. CASLIB:  C Library for CAS Developers                         4-1
  1451. 4-1                         CASLIB:  C Library for CAS Developers
  1452.  
  1453.  
  1454. CASLIB Functions Grouped by Operation
  1455.      The CASLIB functions can be divided into five groups:
  1456.  
  1457.      ╖ Configuration
  1458.      ╖ Event and Queue Queries
  1459.      ╖ Event Creation
  1460.      ╖ Event Manipulation
  1461.      ╖ File Management
  1462.  
  1463.  
  1464. Configuration
  1465.      These functions get information about whether the Resident Manager is
  1466.      installed, the status and condition of the hardware, and the current
  1467.      setup configuration.
  1468.  
  1469.      CASAutoReceiveState      Determines or sets the current state of the
  1470.                               auto-receive feature.
  1471.  
  1472.      CASGetExternalData       Gets the External Data Block (EDB) in an EDB
  1473.                               structure.
  1474.  
  1475.      CASGetHardwareStatus     Gets hardware-specific status information.
  1476.  
  1477.      CASGetInstalledState     Determines whether the Resident Manager is
  1478.                               installed.
  1479.  
  1480.      CASRunDiagnostics        Runs a set of diagnostics or reports on their
  1481.                               progress.
  1482.  
  1483.      CASUnloadResidentManager Removes the Resident Manager from memory.
  1484.  
  1485.  
  1486. Event and Queue Queries
  1487.      These functions get information about events in the Task and Receive
  1488.      queues and the Log.
  1489.  
  1490.      CASFindFirst             Finds the earliest or latest event in the
  1491.                               chosen queue that matches the given status
  1492.                               and chronological direction.
  1493.  
  1494.      CASFindNext              Finds the next event in the queue according
  1495.                               to the settings of the last call to
  1496.                               CASFindFirst.
  1497.  
  1498.      CASGetCurrentEventStatus Gets information about the currently
  1499.                               executing event.
  1500.  
  1501.      CASGetEventDate          Gets the date an event is scheduled to occur.
  1502.  
  1503.      CASGetEventTime          Gets the time an event is scheduled to occur.
  1504.  
  1505.      CASGetQueueStatus        Gets status information about the specified
  1506.                               queue.
  1507.  
  1508.  
  1509. Event Creation
  1510.      These functions submit events to be sent to the Resident Manager.
  1511.      These events are defined either in Control Files or data structures in
  1512.      memory.  These functions do not create those Control Files or
  1513.      initialize those structures.
  1514.  
  1515.  
  1516. 4-2                         CASLIB:  C Library for CAS Developers
  1517.  
  1518.  
  1519.      CASSubmitSingleFile      Submits a Send event specified in a data
  1520.                               structure to the Resident Manager.
  1521.  
  1522.      CASSubmitTask            Submits the event specified in a Control File
  1523.                               to the Resident Manager.
  1524.  
  1525.  
  1526. Event Manipulation
  1527.      These functions manipulate events either by rescheduling events or by
  1528.      aborting the current event.
  1529.  
  1530.      CASAbortCurrentEvent     Aborts the currently executing event.
  1531.  
  1532.      CASSetTaskDate           Changes the event's scheduled execution date
  1533.                               in the Control File.
  1534.  
  1535.      CASSetTaskTime           Changes the event's scheduled execution time
  1536.                               in the Control File.
  1537.  
  1538.  
  1539. File Management
  1540.      These functions provide access to files associated with events.  They
  1541.      access the Control File for the event, or, in the case of Receive
  1542.      events, they access either the Control File or one of the files
  1543.      received.
  1544.  
  1545.      CASDeleteAllFiles        Deletes all the files associated with all the
  1546.                               events in the specified queue.
  1547.  
  1548.      CASDeleteFile            Deletes a file associated with the specified
  1549.                               event.
  1550.  
  1551.      CASMoveReceivedFile      Moves and renames a received file to the
  1552.                               specified directory and filename.
  1553.  
  1554.      CASOpenFile              Opens a file associated with the specified
  1555.                               event.
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582. CASLIB:  C Library for CAS Developers                         4-3
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588. 02H
  1589. CASAbortCurrentEvent
  1590.  
  1591.  
  1592. Description
  1593.      Aborts the currently executing event.  Aborting the event is not
  1594.      instantaneous.  It can take up to 30 seconds.
  1595.  
  1596.  
  1597. Summary
  1598.      #include <cas.h>
  1599.      int PASCAL CASAbortCurrentEvent (void);
  1600.  
  1601.  
  1602. Input Parameter
  1603.      None.
  1604.  
  1605.  
  1606. Output Parameter
  1607.      None.
  1608.  
  1609.  
  1610. Return Value
  1611.      Returns the event handle of the aborted event if successful;
  1612.      otherwise, returns a negative CAS error code.
  1613.  
  1614.  
  1615. See Also
  1616.      CASDeleteFile (08H)
  1617.  
  1618.  
  1619. Example Program
  1620.      The following program aborts the currently executing event, if there
  1621.      is one.
  1622.  
  1623.      #include <stdio.h>
  1624.      #include <cas.h>
  1625.  
  1626.      main ()
  1627.      {
  1628.        int retval;
  1629.  
  1630.        retval = CASAbortCurrentEvent();
  1631.        if (retval > 0) {
  1632.          printf("Event 0X%X has been aborted\n",
  1633.                 retval);
  1634.        }
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648. 4-4                         CASLIB:  C Library for CAS Developers
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.                                                              02H
  1655.                                             CASAbortCurrentEvent
  1656.        else {
  1657.          printf("AbortCurrentEvent error code is: %X",
  1658.                  -retval);
  1659.        }
  1660.      }
  1661.  
  1662.  
  1663.  
  1664.  
  1665.  
  1666.  
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685.  
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714. CASLIB:  C Library for CAS Developers                         4-5
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720. 0FH
  1721. CASAutoReceiveState
  1722.  
  1723.  
  1724. Description
  1725.      Determines or sets the current state of the auto-receive feature.  If
  1726.      an event is in progress, the new auto-receive state does not take
  1727.      effect until the event is completed.
  1728.  
  1729.  
  1730. Summary
  1731.      #include <cas.h>
  1732.      int PASCAL CASAutoReceiveState (mode, rings);
  1733.  
  1734.  
  1735. Input Parameter
  1736.      BYTE mode;     GET to get the current auto-receive state.  SET to set
  1737.                     the auto-receive state.  If mode is GET, rings returns
  1738.                     the number of rings currently set.  If mode is SET, the
  1739.                     number of rings is set to rings.
  1740.  
  1741.  
  1742. Output Parameter
  1743.      BYTE *rings;   Pointer to the number of rings before answer or 0 to
  1744.                     disable if mode is SET.  If the result is AR_ON, rings
  1745.                     contains the number of rings before the hardware
  1746.                     answers.
  1747.  
  1748.  
  1749. Return Value
  1750.      Returns AR_ON or AR_OFF to indicate the auto-receive state if
  1751.      successful; otherwise, returns a negative CAS error code.
  1752.  
  1753.  
  1754. Example Program
  1755.      The following program determines whether auto-answer is on or off, and
  1756.      if on, how many rings the hardware is set to before it answers.
  1757.  
  1758.      #include <stdio.h>
  1759.      #include <cas.h>
  1760.  
  1761.      main ()
  1762.      {
  1763.        int retval;
  1764.        BYTE rings;
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780. 4-6                         CASLIB:  C Library for CAS Developers
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.                                                              0FH
  1787.                                              CASAutoReceiveState
  1788.        retval = CASAutoReceiveState(GET, &rings);
  1789.        if (!(retval < 0)) {
  1790.          switch (retval) {
  1791.            case AR_ON:
  1792.              printf ("RM will answer at %d rings\n",
  1793.                      rings);
  1794.              break;
  1795.            case AR_OFF:
  1796.              printf("RM AutoReceive is OFF\n");
  1797.          }
  1798.        }
  1799.      }
  1800.  
  1801.  
  1802.  
  1803.  
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809.  
  1810.  
  1811.  
  1812.  
  1813.  
  1814.  
  1815.  
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846. CASLIB:  C Library for CAS Developers                         4-7
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852. 09H
  1853. CASDeleteAllFiles
  1854.  
  1855.  
  1856. Description
  1857.      Deletes all the files associated with all the events in the specific
  1858.      queue.
  1859.  
  1860.  
  1861. Summary
  1862.      #include <cas.h>
  1863.      int PASCAL CASDeleteAllFiles (queue);
  1864.  
  1865.  
  1866. Input Parameter
  1867.      BYTE queue;    TASK_QUEUE, RECEIVE_QUEUE, or LOG_QUEUE.
  1868.  
  1869.  
  1870. Output Parameter
  1871.      None.
  1872.  
  1873.  
  1874. Return Value
  1875.      Returns 0 if successful; otherwise, returns a negative CAS error code.
  1876.  
  1877.  
  1878. Remarks
  1879.      Whenever CASDeleteAllFiles deletes all received files of an event, the
  1880.      Resident Manager sets the FileStatus field in the received files' FTR
  1881.      in the Log Control File for that event.  This function deletes all
  1882.      Task Control files, all Received Control files and the associated
  1883.      received files, or all Log Control files.
  1884.  
  1885.  
  1886. See Also
  1887.      CASAbortCurrentEvent (02H), CASDeleteFile (08H)
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912. 4-8                         CASLIB:  C Library for CAS Developers
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.                                                              09H
  1919.                                                CASDeleteAllFiles
  1920. Example Program
  1921.      The following program deletes all events scheduled to execute.
  1922.  
  1923.      #include <stdio.h>
  1924.      #include <cas.h>
  1925.  
  1926.      main ()
  1927.      {
  1928.        int retval;
  1929.  
  1930.        retval = CASDeleteAllFiles(TASK_QUEUE);
  1931.        if (!retval) {
  1932.          printf("All pending events cancelled\n");
  1933.        }
  1934.      }
  1935.  
  1936.  
  1937.  
  1938.  
  1939.  
  1940.  
  1941.  
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947.  
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978. CASLIB:  C Library for CAS Developers                         4-9
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984. 08H
  1985. CASDeleteFile
  1986.  
  1987.  
  1988. Description
  1989.      Deletes the indicated file associated with the specified event.
  1990.  
  1991.  
  1992. Summary
  1993.      #include <cas.h>
  1994.      int PASCAL CASDeleteFile (handle, file, queue);
  1995.  
  1996.  
  1997. Input Parameters
  1998.      int handle;    Event handle associated with the file to delete.
  1999.  
  2000.      int file;      For events in the Receive Queue, either 0 for the
  2001.                     Receive Control File and all that event's received
  2002.                     files, or the received file's number to be deleted.
  2003.                     This number applies only to events in the Receive Queue
  2004.                     and is ignored for events in the Task Queue and the
  2005.                     Log.  The number is interpreted as follows:
  2006.                     0 - Delete all files associated with the specified
  2007.                     Receive Control
  2008.                           File (including the Receive Control File).
  2009.                     1 - Delete the first received file associated with the
  2010.                     event handle.
  2011.                     2 - Delete the second received file associated with the
  2012.                     event
  2013.                           handle.
  2014.                     n - Delete the nth received file associated with the
  2015.                     event handle.
  2016.  
  2017.      BYTE queue;    TASK_QUEUE, RECEIVE_QUEUE, or LOG_QUEUE.
  2018.  
  2019.  
  2020. Output Parameter
  2021.      None.
  2022.  
  2023.  
  2024. Return Value
  2025.      Returns 0 if successful; otherwise, returns a negative CAS error code.
  2026.  
  2027.  
  2028. Remarks
  2029.      Whenever CASDeleteFile deletes a received file, the Resident Manager
  2030.      sets the FileStatus field in the received file's FTR in both the
  2031.      Receive Control File and the Log Control File.
  2032.  
  2033.  
  2034. See Also
  2035.      CASAbortCurrentEvent (02H), CASDeleteAllFiles (09H)
  2036.  
  2037.  
  2038. Example Program
  2039.      The following program finds the first event in the Log Queue and
  2040.      deletes its Control File.
  2041.  
  2042.      #include <stdio.h>
  2043.      #include <cas.h>
  2044. 4-10                        CASLIB:  C Library for CAS Developers
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.                                                              08H
  2051.                                                    CASDeleteFile
  2052.  
  2053.      main ()
  2054.      {
  2055.        int retval, event_hdl;
  2056.  
  2057.        event_hdl = CASFindFirst(ANY_STATUS,
  2058.                                 SEARCH_FORWARD,
  2059.                                 LOG_QUEUE);
  2060.        if (event_hdl == -NO_MORE_EVENTS) {
  2061.          printf("No logged events\n");
  2062.        }
  2063.        else {
  2064.          retval = CASDeleteFile(event_hdl,
  2065.                                 0,
  2066.                                 LOG_QUEUE);
  2067.          if (!retval) {
  2068.            printf("1st logged event file deleted\n");
  2069.          }
  2070.        }
  2071.      }
  2072.  
  2073.  
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110. CASLIB:  C Library for CAS Developers                        4-11
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116. 05H
  2117. CASFindFirst
  2118.  
  2119.  
  2120. Description
  2121.      Finds the earliest or latest event in the chosen queue that matches
  2122.      the given status and chronological direction.
  2123.  
  2124.  
  2125. Summary
  2126.      #include <cas.h>
  2127.      int PASCAL CASFindFirst (status, direction, queue);
  2128.  
  2129.  
  2130. Input Parameters
  2131.      int status;    ANY_STATUS, COMPLETED, WAITING, DIALED, SENDING,
  2132.                     RECEIVING, ABORTED, or negative CAS error code.
  2133.  
  2134.      BYTE direction;                    SEARCH_FORWARD (chronologically from the first
  2135.                     occurring event to the last occurring event) or
  2136.                     SEARCH_BACKWARD (chronologically from the last
  2137.                     occurring event to the first occurring event).
  2138.  
  2139.      BYTE queue;    TASK_QUEUE, RECEIVE_QUEUE or LOG_QUEUE.
  2140.  
  2141.  
  2142. Output Parameter
  2143.      None.
  2144.  
  2145.  
  2146. Return Value
  2147.      Returns the event handle of the event found if successful; otherwise,
  2148.      returns a negative CAS error code.
  2149.  
  2150.  
  2151.  
  2152.      NOTE:
  2153.           If there are no events in the chosen queue that match the given
  2154.           status, a negative CAS error code is returned.  The negative (2's
  2155.           complement) of this error code is 0204H, NO_MORE_EVENTS.
  2156.  
  2157.  
  2158. See Also
  2159.      CASFindNext (06H), CASOpenFile (07H)
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176. 4-12                        CASLIB:  C Library for CAS Developers
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.                                                              05H
  2183.                                                     CASFindFirst
  2184. Example Program
  2185.      The following program finds the event in the Task Queue that is
  2186.      scheduled to execute the earliest.
  2187.  
  2188.      #include <stdio.h>
  2189.      #include <cas.h>
  2190.  
  2191.      main ()
  2192.      {
  2193.        int retval;
  2194.  
  2195.        retval = CASFindFirst(ANY_STATUS,
  2196.                              SEARCH_FORWARD,
  2197.                              TASK_QUEUE);
  2198.        if (retval == -NO_MORE_EVENTS) {
  2199.          printf("No events in Task Queue\n");
  2200.        }
  2201.        else if (retval > 0) {
  2202.          printf("First pending event is # 0X%X\n",
  2203.                  retval);
  2204.        }
  2205.      }
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242. CASLIB:  C Library for CAS Developers                        4-13
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248. 06H
  2249. CASFindNext
  2250.  
  2251.  
  2252. Description
  2253.      Finds the next event in the queue according to the settings of the
  2254.      last call to CASFindFirst.  Each subsequent call to the CASFindNext
  2255.      function returns the event handle of the next event using the same
  2256.      direction and status parameters set by the CASFindFirst function in
  2257.      the specified queue.
  2258.  
  2259.  
  2260. Summary
  2261.      #include <cas.h>
  2262.      int PASCAL CASFindNext (queue);
  2263.  
  2264.  
  2265. Input Parameter
  2266.      BYTE queue;    TASK_QUEUE, RECEIVE_QUEUE, or LOG_QUEUE.
  2267.  
  2268.  
  2269. Output Parameter
  2270.      None.
  2271.  
  2272.  
  2273. Return Value
  2274.      Returns the event handle of the event found if successful; otherwise,
  2275.      returns a negative CAS error code.
  2276.  
  2277.  
  2278.  
  2279.      NOTE:
  2280.           If there are no events in the chosen queue that match the given
  2281.           status, a negative CAS error code is returned.  The negative (2's
  2282.           complement) of this error code is 0204H, NO_MORE_EVENTS.
  2283.  
  2284.  
  2285. See Also
  2286.      CASFindFirst (05H), CASOpenFile (07H)
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308. 4-14                        CASLIB:  C Library for CAS Developers
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.                                                              06H
  2315.                                                      CASFindNext
  2316. Example Program
  2317.      The following program finds all the events in the Log Queue.
  2318.  
  2319.      #include <stdio.h>
  2320.      #include <cas.h>
  2321.  
  2322.      main ()
  2323.      {
  2324.        int retval;
  2325.  
  2326.        retval = CASFindFirst (ANY_STATUS,
  2327.                               SEARCH_FORWARD,
  2328.                               LOG_QUEUE);
  2329.        if (retval == -NO_MORE_EVENTS) {
  2330.          printf("No events in Log Queue\n");
  2331.        }
  2332.        else if (retval > 0) {
  2333.          printf("First logged event is 0X%X\n",
  2334.                  retval);
  2335.        }
  2336.        while (retval != -NO_MORE_EVENTS) {
  2337.          retval = CASFindNext(LOG_QUEUE);
  2338.          if (retval > 0) {
  2339.            printf("Next logged event is 0X%X\n",
  2340.                   retval);
  2341.          }
  2342.        }
  2343.      }
  2344.  
  2345.  
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352.  
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.  
  2372.  
  2373.  
  2374. CASLIB:  C Library for CAS Developers                        4-15
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380. 10H
  2381. CASGetCurrentEventStatus
  2382.  
  2383.  
  2384. Description
  2385.      Gets information about the currently executing event.
  2386.  
  2387.  
  2388. Summary
  2389.      #include <cas.h>
  2390.      int PASCAL CASGetCurrentEventStatus (buffer);
  2391.  
  2392.  
  2393. Input Parameter
  2394.      None.
  2395.  
  2396.  
  2397. Output Parameter
  2398.      CECS *buffer;  Pointer to a valid Current Event Control Structure
  2399.                     (CECS).  If the call is successful, the CECS structure
  2400.                     is filled in with information about the current event.
  2401.                     See the Get Current Event Status function (10H) in the
  2402.                     DCA/Intel Communicating Applications Specification for
  2403.                     information on the CECS structure.
  2404.  
  2405.  
  2406. Return Value
  2407.      Returns the event handle of the current event if successful;
  2408.      otherwise, returns a negative CAS error code.
  2409.  
  2410.  
  2411. Example Program
  2412.      The following program gets information about the status of the
  2413.      currently executing event, if there is one.
  2414.  
  2415.      #include <stdio.h>
  2416.      #include <cas.h>
  2417.  
  2418.      main ()
  2419.      {
  2420.        int retval;
  2421.        CECS event;
  2422.  
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.  
  2440. 4-16                        CASLIB:  C Library for CAS Developers
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.                                                              10H
  2447.                                         CASGetCurrentEventStatus
  2448.        retval = CASGetCurrentEventStatus(&event);
  2449.        if (retval > 0) {
  2450.          printf("Event currently executing, 0X%x,\n",
  2451.                 retval);
  2452.          printf("   is sending file %s to %s\n",
  2453.                 event.CurrentFileInTransit.FileName,
  2454.                 event.ControlFile.DestinationName);
  2455.        }
  2456.        else {
  2457.          printf("No event currently executing\n");
  2458.        }
  2459.      }
  2460.      
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.  
  2476.  
  2477.  
  2478.  
  2479.  
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  
  2486.  
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506. CASLIB:  C Library for CAS Developers                        4-17
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512. 0AH
  2513. CASGetEventDate
  2514.  
  2515.  
  2516.  
  2517. Description
  2518.      Gets the date an event is scheduled to occur.
  2519.  
  2520.  
  2521. Summary
  2522.      #include <cas.h>
  2523.      int PASCAL CASGetEventDate (handle, queue, date);
  2524.  
  2525.  
  2526. Input Parameters
  2527.      int handle;    Event handle of the event to query.
  2528.  
  2529.      BYTE queue;    TASK_QUEUE, RECEIVE_QUEUE, or LOG_QUEUE.
  2530.  
  2531.  
  2532. Output Parameter
  2533.      CAS_DATE *date;                    Pointer to a CAS_DATE structure.  If successful, the
  2534.                     CAS_DATE structure is filled in with information from
  2535.                     the specified event.
  2536.  
  2537.  
  2538. Return Value
  2539.      Returns 0 if successful; otherwise, returns a negative CAS error code.
  2540.  
  2541.  
  2542. See Also
  2543.      CASSetTaskDate (0BH), CASGetEventTime (0CH)
  2544.  
  2545.  
  2546. Example Program
  2547.      The following program gets the date of the oldest Receive event in the
  2548.      Receive Queue.
  2549.  
  2550.      #include <stdio.h>
  2551.      #include <cas.h>
  2552.  
  2553.      main ()
  2554.      {
  2555.        int event_hdl, retval;
  2556.        CAS_DATE date;
  2557.  
  2558.        event_hdl = CASFindFirst(ANY_STATUS,
  2559.                                 SEARCH_FORWARD,
  2560.                                 RECEIVE_QUEUE);
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572. 4-18                        CASLIB:  C Library for CAS Developers
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.                                                              0AH
  2579.                                                  CASGetEventDate
  2580.        if (event_hdl > 0) {
  2581.          retval = CASGetEventDate(event_hdl,
  2582.                                   RECEIVE_QUEUE,
  2583.                                   &date);
  2584.          if (!retval) {
  2585.            printf ("Event was received on %d/%d/%d\n",
  2586.                    date.Month,
  2587.                    date.Day,
  2588.                    date.Year);
  2589.          }
  2590.        }
  2591.      }
  2592.  
  2593.  
  2594.  
  2595.  
  2596.  
  2597.  
  2598.  
  2599.  
  2600.  
  2601.  
  2602.  
  2603.  
  2604.  
  2605.  
  2606.  
  2607.  
  2608.  
  2609.  
  2610.  
  2611.  
  2612.  
  2613.  
  2614.  
  2615.  
  2616.  
  2617.  
  2618.  
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.  
  2634.  
  2635.  
  2636.  
  2637.  
  2638. CASLIB:  C Library for CAS Developers                        4-19
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644. 0CH
  2645. CASGetEventTime
  2646.  
  2647.  
  2648. Description
  2649.      Gets the time an event is scheduled to occur.
  2650.  
  2651.  
  2652. Summary
  2653.      #include <cas.h>
  2654.      int PASCAL CASGetEventTime (handle, queue, time);
  2655.  
  2656.  
  2657. Input Parameters
  2658.      int handle;    Event handle of the event to query.
  2659.  
  2660.      BYTE queue;    TASK_QUEUE, RECEIVE_QUEUE, or LOG_QUEUE.
  2661.  
  2662.  
  2663. Output Parameter
  2664.      CAS_TIME *time;                    Pointer to a CAS_TIME structure.  If successful, the
  2665.                     CAS_TIME structure is filled in with information for
  2666.                     the specified event.
  2667.  
  2668.  
  2669. Return Value
  2670.      Returns 0 if successful; otherwise, returns a negative CAS error code.
  2671.  
  2672.  
  2673. See Also
  2674.      CASGetEventDate (0AH), CASSetTaskTime (0DH)
  2675.  
  2676.  
  2677. Example Program
  2678.      The following program gets the execute time of the first event in the
  2679.      Receive Queue.
  2680.  
  2681.      #include <stdio.h>
  2682.      #include <cas.h>
  2683.  
  2684.      main ()
  2685.      {
  2686.        int event_hdl, retval;
  2687.        CAS_TIME time;
  2688.  
  2689.        event_hdl = CASFindFirst(ANY_STATUS,
  2690.                                 SEARCH_FORWARD,
  2691.                                 RECEIVE_QUEUE);
  2692.        if (event_hdl > 0) {
  2693.          retval = CASGetEventTime(event_hdl,
  2694.                                   RECEIVE_QUEUE,
  2695.                                   &time);
  2696.          if (!retval) {
  2697.            printf("Event was received at %d:%d:%d\n",
  2698.                   time.Hour,
  2699.                   time.Minute,
  2700.                   time.Second);
  2701.          }
  2702.        }
  2703.      }
  2704. 4-20                        CASLIB:  C Library for CAS Developers
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.                                                              0EH
  2711.                                               CASGetExternalData
  2712.  
  2713.  
  2714. Description
  2715.      Returns the External Data Block (EDB) in an EDB structure.
  2716.  
  2717.  
  2718. Summary
  2719.      #include <cas.h>
  2720.      int PASCAL CASGetExternalData (buffer);
  2721.  
  2722.  
  2723. Input Parameter
  2724.      None.
  2725.  
  2726.  
  2727. Output Parameter
  2728.      EDB *buffer;   Pointer to a valid EDB structure.  See the Get External
  2729.                     Data Block function (0EH) in the DCA/Intel
  2730.                     Communicating Applications Specification for additional
  2731.                     information on the EDB structure.  If successful, the
  2732.                     EDB structure is filled with the EDB information.
  2733.  
  2734.  
  2735. Return Value
  2736.      Returns 0 if successful; otherwise, returns a negative CAS error code.
  2737.  
  2738.  
  2739. Example Program
  2740.      The following program accesses the EDB to determine the version
  2741.      numbers of the Resident Manager.
  2742.  
  2743.      #include <stdio.h>
  2744.      #include <cas.h>
  2745.  
  2746.      main ()
  2747.      {
  2748.        int retval;
  2749.        EDB edb;
  2750.  
  2751.        retval = CASGetExternalData(&edb);
  2752.        if (!retval) {
  2753.          printf("Installed Resident Manager version is: %d.%d\n",
  2754.                  (int)edb.CASMajorVer,
  2755.                  (int)edb.CASMinorVer);
  2756.        }
  2757.      }
  2758.  
  2759.  
  2760.  
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767.  
  2768.  
  2769.  
  2770. CASLIB:  C Library for CAS Developers                        4-21
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776. 12H
  2777. CASGetHardwareStatus
  2778.  
  2779.  
  2780. Description
  2781.      Returns the hardware-specific status information of the communications
  2782.      hardware in a HWSTAT structure.  For information on the content and
  2783.      format of the hardware status structure for the Intel Connection
  2784.      CoProcessor, refer to the Hardware-Specific Information for Intel
  2785.      Communications Products Supporting the DCA/Intel Communicating
  2786.      Applications Specification provided with the Toolkit.
  2787.  
  2788.  
  2789. Summary
  2790.      #include <cas.h>
  2791.      int PASCAL CASGetHardwareStatus (buffer);
  2792.  
  2793.  
  2794. Input Parameter
  2795.      None.
  2796.  
  2797.  
  2798. Output Parameter
  2799.      HWSTAT *buffer;                    Pointer to a 128-byte area in which hardware status
  2800.                     information is returned.
  2801.  
  2802.  
  2803. Return Value
  2804.      Returns 0 if successful, otherwise, returns a negative CAS error.
  2805.  
  2806.  
  2807. See Also
  2808.      CASGetTaskStatus (10H), CASGetQueueStatus (11H)
  2809.  
  2810.  
  2811. Example Program
  2812.      The following program gets and displays (in hexadecimal) all the bytes
  2813.      in the hardware-specific status information structure.
  2814.  
  2815.      #include <stdio.h>
  2816.      #include <cas.h>
  2817.  
  2818.      main ()
  2819.      {
  2820.        int retval, i;
  2821.        BYTE val;
  2822.        HWSTAT status;
  2823.  
  2824.  
  2825.  
  2826.  
  2827.  
  2828.  
  2829.  
  2830.  
  2831.  
  2832.  
  2833.  
  2834.  
  2835.  
  2836. 4-22                        CASLIB:  C Library for CAS Developers
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842.                                                              12H
  2843.                                             CASGetHardwareStatus
  2844.        retval = CASGetHardwareStatus(&status);
  2845.        if (!(retval)) {
  2846.          printf("HW status info, as hex bytes:\n");
  2847.          for (i=0; i<sizeof(HWSTAT); i++) {
  2848.            printf(" %02X", val = ((char *)&status)[i]);
  2849.          }
  2850.          printf("\n");
  2851.        }
  2852.        else {
  2853.          printf("GetHardwareStatus error code is: %X\n",
  2854.                  -retval);
  2855.        }
  2856.      }
  2857.  
  2858.  
  2859.  
  2860.  
  2861.  
  2862.  
  2863.  
  2864.  
  2865.  
  2866.  
  2867.  
  2868.  
  2869.  
  2870.  
  2871.  
  2872.  
  2873.  
  2874.  
  2875.  
  2876.  
  2877.  
  2878.  
  2879.  
  2880.  
  2881.  
  2882.  
  2883.  
  2884.  
  2885.  
  2886.  
  2887.  
  2888.  
  2889.  
  2890.  
  2891.  
  2892.  
  2893.  
  2894.  
  2895.  
  2896.  
  2897.  
  2898.  
  2899.  
  2900.  
  2901.  
  2902. CASLIB:  C Library for CAS Developers                        4-23
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908. 00H
  2909. CASGetInstalledState
  2910.  
  2911.  
  2912. Description
  2913.      Determines whether the Resident Manager is currently installed, and if
  2914.      not, whether it can be installed.
  2915.  
  2916.  
  2917. Summary
  2918.      #include <cas.h>
  2919.      int PASCAL CASGetInstalledState (void);
  2920.  
  2921.  
  2922. Input Parameter
  2923.      None.
  2924.  
  2925.  
  2926. Output Parameter
  2927.      None.
  2928.  
  2929.  
  2930. Return Value
  2931.      Returns one of the following constants:
  2932.  
  2933.      INSTALLED if Resident Manager is installed.
  2934.      NOTiOK if Resident Manager is NOT installed but can be installed.
  2935.      NOTiNO if Resident Manager is NOT installed and can't be installed.
  2936.  
  2937.  
  2938. See Also
  2939.      CASGetExternalData (0EH)
  2940.  
  2941.  
  2942.  
  2943.  
  2944.  
  2945.  
  2946.  
  2947.  
  2948.  
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.  
  2968. 4-24                        CASLIB:  C Library for CAS Developers
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.                                                              00H
  2975.                                             CASGetInstalledState
  2976. Example Program
  2977.      The following program determines whether the Resident Manager is
  2978.      installed.
  2979.  
  2980.      #include <stdio.h>
  2981.      #include <cas.h>
  2982.  
  2983.      main ()
  2984.      {
  2985.          int retval;
  2986.  
  2987.          retval = CASGetInstalledState();
  2988.          if (retval == INSTALLED) {
  2989.              printf("Resident Manager is installed\n");
  2990.          }
  2991.          else {
  2992.             printf("Resident Manager is not installed\n");
  2993.          }
  2994.      }
  2995.  
  2996.  
  2997.  
  2998.  
  2999.  
  3000.  
  3001.  
  3002.  
  3003.  
  3004.  
  3005.  
  3006.  
  3007.  
  3008.  
  3009.  
  3010.  
  3011.  
  3012.  
  3013.  
  3014.  
  3015.  
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021.  
  3022.  
  3023.  
  3024.  
  3025.  
  3026.  
  3027.  
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033.  
  3034. CASLIB:  C Library for CAS Developers                        4-25
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040. 11H
  3041. CASGetQueueStatus
  3042.  
  3043.  
  3044. Description
  3045.      Gets status information about the specified queue in a QSTAT
  3046.      structure.  The QSTAT fields are described in the comments to the
  3047.      QSTAT definition in the file CAS.H.
  3048.  
  3049.  
  3050. Summary
  3051.      #include <cas.h>
  3052.      int PASCAL CASGetQueueStatus (queue, buffer);
  3053.  
  3054.  
  3055. Input Parameter
  3056.      BYTE queue;    The queue to check (TASK_QUEUE, RECEIVE_QUEUE, or
  3057.                     LOG_QUEUE).
  3058.  
  3059.  
  3060. Output Parameter
  3061.      QSTAT *buffer; Pointer to a QSTAT structure.  If successful, the QSTAT
  3062.                     buffer is filled with the current status of the
  3063.                     specified queue.
  3064.  
  3065.  
  3066. Return Value
  3067.      Returns 0 if successful; otherwise, returns a negative CAS error code.
  3068.  
  3069.  
  3070. Remarks
  3071.      This function returns the following: the total number of changes made
  3072.      to the queue since the Resident Manager was started, the current
  3073.      number of Control Files in the queue, and the current number of
  3074.      received files.
  3075.  
  3076.  
  3077. Example Program
  3078.      The following program gets status information about the Log Queue.
  3079.  
  3080.      #include <stdio.h>
  3081.      #include <cas.h>
  3082.  
  3083.      main ()
  3084.      {
  3085.        int retval;
  3086.        QSTAT buffer;
  3087.  
  3088.        retval = CASGetQueueStatus(LOG_QUEUE, &buffer);
  3089.        if (!retval) {
  3090.          printf("Log Queue status:\n");
  3091.          printf("   Number of logged events: %d\n",
  3092.                 buffer.QControlFiles);
  3093.          printf("   Changes since last installed: %d\n",
  3094.                 buffer.QChanges);
  3095.        }
  3096.        else {
  3097.          printf("GetQueueStatus failed,\n");
  3098.          printf("CAS error code is 0X%X\n", -retval);
  3099.        }
  3100. 4-26                        CASLIB:  C Library for CAS Developers
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106.                                                              11H
  3107.                                                CASGetQueueStatus
  3108.      }
  3109.  
  3110.  
  3111.  
  3112.  
  3113.  
  3114.  
  3115.  
  3116.  
  3117.  
  3118.  
  3119.  
  3120.  
  3121.  
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  
  3127.  
  3128.  
  3129.  
  3130.  
  3131.  
  3132.  
  3133.  
  3134.  
  3135.  
  3136.  
  3137.  
  3138.  
  3139.  
  3140.  
  3141.  
  3142.  
  3143.  
  3144.  
  3145.  
  3146.  
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166. CASLIB:  C Library for CAS Developers                        4-27
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172. 14H
  3173. CASMoveReceivedFile
  3174.  
  3175.  
  3176. Description
  3177.      Moves and renames a received file to the directory and filename
  3178.      specified in *filespec.
  3179.  
  3180.  
  3181. Summary
  3182.      #include <cas.h>
  3183.      int PASCAL CASMoveReceivedFile (handle, file, filespec);
  3184.  
  3185.  
  3186. Input Parameters
  3187.      int handle;         Event handle of the Receive event.
  3188.  
  3189.      int file;           The received file to move.  Must be non-zero to
  3190.                          specify a received file.  The number is
  3191.                          interpreted as follows:
  3192.                          1 - First received file
  3193.                          2 - Second received file
  3194.                          3 - Third received file
  3195.                          n - nth received file.
  3196.  
  3197.      char *filespec;     Pointer to a fully qualified NULL terminated
  3198.                          string specifying the new path and filename.
  3199.  
  3200.  
  3201. Output Parameter
  3202.      None.
  3203.  
  3204.  
  3205. Return Value
  3206.      Returns 0 if successful; otherwise, returns a negative CAS error code.
  3207.  
  3208.  
  3209. Remarks
  3210.      The path in *filespec must already exist.  The file named by *filespec
  3211.      must not already exist or an error results.  This function does not
  3212.      create directories.  The *filespec can specify any disk drive
  3213.      physically in the system.
  3214.  
  3215.      Whenever CASMoveReceivedFile moves a received file, the Resident
  3216.      Manager sets the FileStatus field in the received file's FTR in both
  3217.      the Receive Control File and the Log Control File.
  3218.  
  3219.  
  3220.  
  3221.  
  3222.  
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232. 4-28                        CASLIB:  C Library for CAS Developers
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.                                                              14H
  3239.                                              CASMoveReceivedFile
  3240. Example Program
  3241.      The following program moves the first received file of the oldest
  3242.      Receive event to drive C: under the name "\received.1".
  3243.  
  3244.      #include <stdio.h>
  3245.      #include <cas.h>
  3246.  
  3247.      main ()
  3248.      {
  3249.        int event_hdl, retval;
  3250.        char *fname = "c:\\received.1";
  3251.  
  3252.        event_hdl = CASFindFirst(ANY_STATUS,
  3253.                                 SEARCH_FORWARD,
  3254.                                 RECEIVE_QUEUE);
  3255.        if (event_hdl > 0) {
  3256.          retval = CASMoveReceivedFile(event_hdl, 1, fname);
  3257.          if (!retval) {
  3258.            printf("First received file saved as %s\n", fname);
  3259.          }
  3260.          else {
  3261.            printf("MoveReceivedFile failed,\n");
  3262.            printf("CAS error code is: 0X%X", -retval);
  3263.          }
  3264.        }
  3265.        else {
  3266.          printf("Error occurred in CASFindFirst");
  3267.        }
  3268.      }
  3269.  
  3270.  
  3271.  
  3272.  
  3273.  
  3274.  
  3275.  
  3276.  
  3277.  
  3278.  
  3279.  
  3280.  
  3281.  
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.  
  3291.  
  3292.  
  3293.  
  3294.  
  3295.  
  3296.  
  3297.  
  3298. CASLIB:  C Library for CAS Developers                        4-29
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304. 07H
  3305. CASOpenFile
  3306.  
  3307.  
  3308. Description
  3309.      Opens a file associated with the specified event.
  3310.  
  3311.  
  3312. Summary
  3313.      #include <cas.h>
  3314.      int PASCAL CASOpenFile (handle, file, queue);
  3315.  
  3316.  
  3317. Input Parameters
  3318.      int handle;    Event handle associated with the file to open.
  3319.  
  3320.      int file;      For events in the Receive Queue, either 0 for the
  3321.                     Receive Control File or the number of the received
  3322.                     file.  This number is interpreted as follows:
  3323.                     0 - The Received Control File
  3324.                     1 - First received file
  3325.                     2 - Second received file
  3326.                     3 - Third received file
  3327.                     n - nth received file.
  3328.  
  3329.                     For events in the Task Queue and the Log, this function
  3330.                     opens the Control File for the event.
  3331.  
  3332.      BYTE queue;    TASK_QUEUE, RECEIVE_QUEUE, or LOG_QUEUE.
  3333.  
  3334.  
  3335. Output Parameter
  3336.      None.
  3337.  
  3338.  
  3339. Return Value
  3340.      Returns the DOS file handle of the opened file if successful;
  3341.      otherwise, returns a negative CAS error code.
  3342.  
  3343.  
  3344. Remarks
  3345.      After you obtain an event handle (either by scanning a queue using the
  3346.      CASFindFirst and CASFindNext functions or by creating an event using
  3347.      the CASSubmitTask function), you can use the CASOpenFile function to
  3348.      access the DOS file corresponding to the event.  CASOpenFile opens the
  3349.      Control File for events in the Task Queue or the Log.  This function
  3350.      opens the desired file in read-only mode and returns a DOS file
  3351.      handle.
  3352.  
  3353.      Whenever CASOpenFile opens a received file, the Resident Manager sets
  3354.      the FileStatus field in the received file's FTR in both the Receive
  3355.      Control File and the Log Control File.
  3356.  
  3357.  
  3358. See Also
  3359.      CASSubmitTask (01H), CASFindFirst (05H), CASFindNext (06H),
  3360.      CASMoveReceivedFile (14H)
  3361.  
  3362.  
  3363.  
  3364. 4-30                        CASLIB:  C Library for CAS Developers
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370.                                                              07H
  3371.                                                      CASOpenFile
  3372. Example Program
  3373.      The following program finds the oldest Receive event in the  Receive
  3374.      Queue and opens its Control File.
  3375.  
  3376.      #include <stdio.h>
  3377.      #include <cas.h>
  3378.  
  3379.      main ()
  3380.      {
  3381.        int event_hdl, file_hdl;
  3382.  
  3383.        event_hdl = CASFindFirst(ANY_STATUS,
  3384.                                 SEARCH_FORWARD,
  3385.                                 RECEIVE_QUEUE);
  3386.        if (event_hdl == -NO_MORE_EVENTS) {
  3387.          printf("No received events\n");
  3388.        }
  3389.        else {
  3390.          file_hdl = CASOpenFile(event_hdl,
  3391.                                 0,
  3392.                                 RECEIVE_QUEUE);
  3393.          if (file_hdl > 0) {
  3394.            printf("Handle for event file: %d\n",
  3395.                    file_hdl);
  3396.          }
  3397.        }
  3398.      }
  3399.  
  3400.  
  3401.  
  3402.  
  3403.  
  3404.  
  3405.  
  3406.  
  3407.  
  3408.  
  3409.  
  3410.  
  3411.  
  3412.  
  3413.  
  3414.  
  3415.  
  3416.  
  3417.  
  3418.  
  3419.  
  3420.  
  3421.  
  3422.  
  3423.  
  3424.  
  3425.  
  3426.  
  3427.  
  3428.  
  3429.  
  3430. CASLIB:  C Library for CAS Developers                        4-31
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436. 13H
  3437. CASRunDiagnostics
  3438.  
  3439.  
  3440. Description
  3441.      Runs a set of diagnostics or reports on their progress.
  3442.  
  3443.  
  3444. Summary
  3445.      #include <cas.h>
  3446.      int PASCAL CASRunDiagnostics (mode);
  3447.  
  3448.  
  3449. Input Parameter
  3450.      BYTE mode;     Determines which diagnostics function to invoke.
  3451.                     Setting mode to a value of START starts the hardware
  3452.                     diagnostics.  Setting mode to a value of STATUS returns
  3453.                     the status of the diagnostics.
  3454.  
  3455.  
  3456. Output Parameter
  3457.      None.
  3458.  
  3459.  
  3460. Return Value
  3461.      Depending on the action specified by mode, this function returns the
  3462.      following results:
  3463.  
  3464.      ╖ START returns 0 if successful (diagnostic begun); otherwise, returns
  3465.        a negative CAS error code.
  3466.  
  3467.      ╖ STATUS returns 40H if the diagnostics are in progress.  It returns a
  3468.        positive value (other than 40H) if the diagnostics are completed
  3469.        successfully.  It returns a negative value if the diagnostics
  3470.        failed.  For information on the values, content, and format of the
  3471.        hardware status structure, refer to the Hardware-Specific
  3472.        Information for Intel Communications Products Supporting the
  3473.        DCA/Intel Communicating Applications Specification provided with the
  3474.        Toolkit.
  3475.  
  3476.  
  3477. Example Program
  3478.      The following program starts and runs to completion the CAS
  3479.      diagnostics.
  3480.  
  3481.      #include <stdio.h>
  3482.      #include <cas.h>
  3483.  
  3484.      main ()
  3485.      {
  3486.        int retval;
  3487.  
  3488.        retval = CASRunDiagnostics(START);
  3489.        if (!retval) {
  3490.          printf("Diagnostics started...\n");
  3491.          do {
  3492.            retval = CASRunDiagnostics(STATUS);
  3493.          } while (retval == 0x40);
  3494.          if (retval >= 0) {
  3495.            printf("Diagnostics successful\n");
  3496. 4-32                        CASLIB:  C Library for CAS Developers
  3497.  
  3498.  
  3499.  
  3500.  
  3501.  
  3502.                                                              13H
  3503.                                                CASRunDiagnostics
  3504.          }
  3505.          else {
  3506.            printf("Diagnostics failed\n");
  3507.            printf("    Failure code is 0X%X", retval);
  3508.          }
  3509.        }
  3510.        else {
  3511.          printf("Diagnostics failed to start,\n");
  3512.          printf("    Failure code is 0X%X", retval);
  3513.        }
  3514.  
  3515.      }
  3516.      
  3517.  
  3518.  
  3519.  
  3520.  
  3521.  
  3522.  
  3523.  
  3524.  
  3525.  
  3526.  
  3527.  
  3528.  
  3529.  
  3530.  
  3531.  
  3532.  
  3533.  
  3534.  
  3535.  
  3536.  
  3537.  
  3538.  
  3539.  
  3540.  
  3541.  
  3542.  
  3543.  
  3544.  
  3545.  
  3546.  
  3547.  
  3548.  
  3549.  
  3550.  
  3551.  
  3552.  
  3553.  
  3554.  
  3555.  
  3556.  
  3557.  
  3558.  
  3559.  
  3560.  
  3561.  
  3562. CASLIB:  C Library for CAS Developers                        4-33
  3563.  
  3564.  
  3565.  
  3566.  
  3567.  
  3568. 0BH
  3569. CASSetTaskDate
  3570.  
  3571.  
  3572. Description
  3573.      Changes the event's scheduled execution date in the Control File.
  3574.      This function works only with events in the Task Queue.
  3575.  
  3576.  
  3577. Summary
  3578.      #include <cas.h>
  3579.      int PASCAL CASSetTaskDate (handle, date);
  3580.  
  3581.  
  3582. Input Parameters
  3583.      int handle;    Event handle of the event to modify.
  3584.  
  3585.      CAS_DATE *date;                    Pointer to a valid, filled-in CAS_DATE structure.
  3586.  
  3587.  
  3588. Output Parameter
  3589.      None.
  3590.  
  3591.  
  3592. Return Value
  3593.      Returns 0 if successful; otherwise, returns a negative CAS error code.
  3594.  
  3595.  
  3596.  
  3597.      NOTE:
  3598.           Setting the date earlier than the current date causes the event
  3599.           to execute immediately.
  3600.  
  3601.  
  3602. See Also
  3603.      CASGetEventDate (0AH), CASSetTaskTime (0DH)
  3604.  
  3605.  
  3606. Example Program
  3607.      The following program changes the execution date of the earliest
  3608.      scheduled Send event in the Task Queue to 1/1/91.
  3609.  
  3610.      #include <stdio.h>
  3611.      #include <cas.h>
  3612.  
  3613.      main ()
  3614.      {
  3615.        int event_hdl, retval;
  3616.        CAS_DATE date;
  3617.  
  3618.        event_hdl = CASFindFirst(ANY_STATUS,
  3619.                                 SEARCH_FORWARD,
  3620.                                 TASK_QUEUE);
  3621.        if (event_hdl > 0) {
  3622.          date.Year = 1991;
  3623.          date.Month = 1;
  3624.          date.Day = 1;
  3625.          retval = CASSetTaskDate(event_hdl, &date);
  3626.          if (!retval) {
  3627.            printf("Event date reset to %d/%d/%d\n",
  3628. 4-34                        CASLIB:  C Library for CAS Developers
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634.                                                              0BH
  3635.                                                   CASSetTaskDate
  3636.                    date.Month,
  3637.                    date.Day,
  3638.                    date.Year);
  3639.          }
  3640.          else {
  3641.            printf("SetTaskDate failed,\n");
  3642.            printf("CAS error code is: 0X%X", -retval);
  3643.          }
  3644.        }
  3645.      }
  3646.  
  3647.  
  3648.  
  3649.  
  3650.  
  3651.  
  3652.  
  3653.  
  3654.  
  3655.  
  3656.  
  3657.  
  3658.  
  3659.  
  3660.  
  3661.  
  3662.  
  3663.  
  3664.  
  3665.  
  3666.  
  3667.  
  3668.  
  3669.  
  3670.  
  3671.  
  3672.  
  3673.  
  3674.  
  3675.  
  3676.  
  3677.  
  3678.  
  3679.  
  3680.  
  3681.  
  3682.  
  3683.  
  3684.  
  3685.  
  3686.  
  3687.  
  3688.  
  3689.  
  3690.  
  3691.  
  3692.  
  3693.  
  3694. CASLIB:  C Library for CAS Developers                        4-35
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700. 0DH
  3701. CASSetTaskTime
  3702.  
  3703.  
  3704. Description
  3705.      Changes the event's scheduled execution time in the Control File.
  3706.      This function works only with events in the Task Queue.
  3707.  
  3708.  
  3709. Summary
  3710.      #include <cas.h>
  3711.      int PASCAL CASSetTaskTime (handle, time);
  3712.  
  3713.  
  3714. Input Parameters
  3715.      int handle;    Event handle of the event to modify.
  3716.  
  3717.      CAS_TIME *time;                    Pointer to a valid, filled in CAS_TIME structure.
  3718.  
  3719.  
  3720. Output Parameter
  3721.      None.
  3722.  
  3723.  
  3724. Return Value
  3725.      Returns 0 if successful; otherwise, returns a negative CAS error code.
  3726.  
  3727.  
  3728.  
  3729.      NOTE:
  3730.           Setting the time earlier than the current time will cause the
  3731.           event to execute immediately if the date is set to the current
  3732.           date.  Therefore, Intel recommends that you change the date
  3733.           before you change the time or you may accidentally send an event
  3734.           before you intend to.
  3735.  
  3736.  
  3737. See Also
  3738.      CASSetTaskDate (0BH), CASGetEventTime (0CH)
  3739.  
  3740.  
  3741. Example Program
  3742.      The following program sets the execute time of the earliest scheduled
  3743.      Send event in the Task Queue to 8:30 a.m.
  3744.  
  3745.      #include <stdio.h>
  3746.      #include <cas.h>
  3747.  
  3748.      main ()
  3749.      {
  3750.        int event_hdl, retval;
  3751.        CAS_TIME time;
  3752.  
  3753.        event_hdl = CASFindFirst(ANY_STATUS,
  3754.                                 SEARCH_FORWARD,
  3755.                                 TASK_QUEUE);
  3756.        if (event_hdl > 0) {
  3757.          time.Hour = 8;
  3758.          time.Minute = 30;
  3759.          time.Second = 0;
  3760. 4-36                        CASLIB:  C Library for CAS Developers
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766.                                                              0DH
  3767.                                                   CASSetTaskTime
  3768.          retval = CASSetTaskTime(event_hdl, &time);
  3769.          if (!retval) {
  3770.            printf("Event time reset to %d:%d:%d\n",
  3771.                    time.Hour,
  3772.                    time.Minute,
  3773.                    time.Second);
  3774.          }
  3775.          else {
  3776.            printf("SetTaskTime failed,\n");
  3777.            printf("CAS error code is 0X%X", -retval);
  3778.          }
  3779.        }
  3780.      }
  3781.  
  3782.  
  3783.  
  3784.  
  3785.  
  3786.  
  3787.  
  3788.  
  3789.  
  3790.  
  3791.  
  3792.  
  3793.  
  3794.  
  3795.  
  3796.  
  3797.  
  3798.  
  3799.  
  3800.  
  3801.  
  3802.  
  3803.  
  3804.  
  3805.  
  3806.  
  3807.  
  3808.  
  3809.  
  3810.  
  3811.  
  3812.  
  3813.  
  3814.  
  3815.  
  3816.  
  3817.  
  3818.  
  3819.  
  3820.  
  3821.  
  3822.  
  3823.  
  3824.  
  3825.  
  3826. CASLIB:  C Library for CAS Developers                        4-37
  3827.  
  3828.  
  3829.  
  3830.  
  3831.  
  3832. 15H
  3833. CASSubmitSingleFile
  3834.  
  3835.  
  3836. Description
  3837.      Submits a Send event specified in a data structure to the Resident
  3838.      Manager.
  3839.  
  3840.  
  3841.  
  3842.      NOTE:
  3843.           To send more than one file, use the CASSubmitTask function.
  3844.  
  3845.  
  3846. Summary
  3847.      #include <cas.h>
  3848.      int PASCAL CASSubmitSingleFile (buffer);
  3849.  
  3850.  
  3851. Input Parameter
  3852.      SFTR *buffer;  Pointer to a data structure containing an abbreviated
  3853.                     version of the information in the Task Control File.
  3854.                     See the Submit a Single File to Send function in the
  3855.                     DCA/Intel Communicating Applications Specification for
  3856.                     more information on the SFTR structure.
  3857.  
  3858.  
  3859. Output Parameter
  3860.      None.
  3861.  
  3862.  
  3863. Return Value
  3864.      Returns the event handle if successful; otherwise, returns a negative
  3865.      CAS error code.
  3866.  
  3867.  
  3868. Remarks
  3869.      The following fields of Control Files and FTRs are not present in the
  3870.      SFTR structure:
  3871.  
  3872.      Sender Name, Logo Filename    CASSubmitSingleFile obtains these from
  3873.                                    the EDB.
  3874.  
  3875.      Page Length in Inches, Page Increments                                   If the transmission is a fax,
  3876.                                    CASSubmitSingleFile uses the standard
  3877.                                    11" page length.
  3878.  
  3879.  
  3880. See Also
  3881.      CASSubmitTask (01H)
  3882.  
  3883.  
  3884.  
  3885.  
  3886.  
  3887.  
  3888.  
  3889.  
  3890.  
  3891.  
  3892. 4-38                        CASLIB:  C Library for CAS Developers
  3893.  
  3894.  
  3895.  
  3896.  
  3897.  
  3898.                                                              15H
  3899.                                              CASSubmitSingleFile
  3900. Example Program
  3901.      The following program creates a SFTR structure for a fax send and
  3902.      submits it to the Resident Manager.
  3903.  
  3904.      #include <stdio.h>
  3905.      #include <malloc.h>
  3906.      #include <string.h>
  3907.      #include <cas.h>
  3908.  
  3909.      main ()
  3910.      {
  3911.        int event_hdl;
  3912.        SFTR *sftr;
  3913.  
  3914.        sftr = (SFTR *)calloc(1, sizeof(SFTR));
  3915.        strcpy(sftr->DestinationName, "lab fax");
  3916.        strcpy(sftr->FileName, "c:\\autoexec.bat");
  3917.        strcpy(sftr->Phone, "9, 645-8468");
  3918.  
  3919.        event_hdl = CASSubmitSingleFile(sftr);
  3920.        if (event_hdl > 0) {
  3921.          printf("Fax send successfully submitted\n");
  3922.        }
  3923.      }
  3924.  
  3925.  
  3926.  
  3927.  
  3928.  
  3929.  
  3930.  
  3931.  
  3932.  
  3933.  
  3934.  
  3935.  
  3936.  
  3937.  
  3938.  
  3939.  
  3940.  
  3941.  
  3942.  
  3943.  
  3944.  
  3945.  
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.  
  3956.  
  3957.  
  3958. CASLIB:  C Library for CAS Developers                        4-39
  3959.  
  3960.  
  3961.  
  3962.  
  3963.  
  3964. 01H
  3965. CASSubmitTask
  3966.  
  3967.  
  3968. Description
  3969.      Submits the event specified in a Control File to the Resident Manager.
  3970.      Before invoking this function, prepare a Control File.
  3971.  
  3972.  
  3973. Summary
  3974.      #include <cas.h>
  3975.      int PASCAL CASSubmitTask (filespec);
  3976.  
  3977.  
  3978. Input Parameter
  3979.      char *filespec;                    Pointer to a complete path and filename of a Control
  3980.                     File.
  3981.  
  3982.  
  3983. Output Parameter
  3984.      None.
  3985.  
  3986.  
  3987. Return Value
  3988.      Returns a positive event handle if successful; otherwise, returns a
  3989.      negative CAS error code.
  3990.  
  3991.  
  3992. Remarks
  3993.      CASSubmitTask adds this Control File to the Task Queue if the event is
  3994.      to be sent in the future.  Otherwise, the Resident Manager sends the
  3995.      event immediately.
  3996.  
  3997.  
  3998. See Also
  3999.      CASSubmitSingleFile (15H)
  4000.  
  4001.  
  4002. Example Program
  4003.      The following program creates a Control File for a Send event and
  4004.      submits it to the Resident Manager.
  4005.  
  4006.      #include <stdio.h>
  4007.      #include <malloc.h>
  4008.      #include <string.h>
  4009.      #include <cas.h>
  4010.  
  4011.      main ()
  4012.      {
  4013.        int event_hdl;
  4014.        FILE *fptr;
  4015.        ECF *ecf;
  4016.        FTR *ftr;
  4017.  
  4018.      /* Allocate and clear Control File structures */
  4019.        ecf = (ECF *)calloc(1, sizeof(ECF));
  4020.        ftr = (FTR *)calloc(1, sizeof(FTR));
  4021.  
  4022.      /* Set specific fields for this send */
  4023.        ecf->FileCount = 1;
  4024. 4-40                        CASLIB:  C Library for CAS Developers
  4025.  
  4026.  
  4027.  
  4028.  
  4029.  
  4030.                                                              01H
  4031.                                                    CASSubmitTask
  4032.        ecf->FTROffset = 383; /* for no cover text */
  4033.        strcpy(ecf->DestinationName, "lab fax");
  4034.        strcpy(ecf->Phone, "9, 645-8468");
  4035.  
  4036.        strcpy(ftr->FileName, "c:\\autoexec.bat");
  4037.  
  4038.      /* Create the Control File and write structures to it */
  4039.        fptr = fopen("c:\\sample.ecf", "wb");
  4040.        fwrite(ecf, sizeof(ECF), 1, fptr);
  4041.        fwrite(ftr, sizeof(FTR), 1, fptr);
  4042.        fclose(fptr);
  4043.  
  4044.      /* Submit the task */
  4045.        event_hdl = CASSubmitTask("c:\\sample.ecf");
  4046.        if (event_hdl > 0) {
  4047.          printf("File %s is on it's way!\n",
  4048.                 "c:\\autoexec.bat");
  4049.        }
  4050.        else {
  4051.          printf("CASSubmitTask error is: 0X%x\n",
  4052.                 -event_hdl);
  4053.        }
  4054.        free(ecf);
  4055.        free(ftr);
  4056.      }
  4057.      
  4058.  
  4059.  
  4060.  
  4061.  
  4062.  
  4063.  
  4064.  
  4065.  
  4066.  
  4067.  
  4068.  
  4069.  
  4070.  
  4071.  
  4072.  
  4073.  
  4074.  
  4075.  
  4076.  
  4077.  
  4078.  
  4079.  
  4080.  
  4081.  
  4082.  
  4083.  
  4084.  
  4085.  
  4086.  
  4087.  
  4088.  
  4089.  
  4090. CASLIB:  C Library for CAS Developers                        4-41
  4091.  
  4092.  
  4093.  
  4094.  
  4095.  
  4096. 16H
  4097. CASUnloadResidentManager
  4098.  
  4099.  
  4100. Description
  4101.      Removes the Resident Manager from memory.  This function can be used
  4102.      to remove the Resident Manager as long as a Terminate and Stay
  4103.      Resident (TSR) has been loaded above the Resident Manager, there is a
  4104.      polled send present, or the Resident Manager or the hardware is busy.
  4105.  
  4106.  
  4107. Summary
  4108.      #include <cas.h>
  4109.      int PASCAL CASUnloadResidentManager(void);
  4110.  
  4111.  
  4112. Input Parameter
  4113.      None.
  4114.  
  4115.  
  4116. Output Parameter
  4117.      None.
  4118.  
  4119.  
  4120. Return Value
  4121.      Returns 0 if successful; otherwise, returns a negative CAS error code.
  4122.  
  4123.  
  4124. Remarks
  4125.      Removing the Resident Manager from memory suspends all pending events.
  4126.      For example, if an event is scheduled to be sent in 5 minutes, it will
  4127.      not be sent until the Resident Manager is reloaded.  After the
  4128.      Resident Manager is reloaded, it will immediately send late events in
  4129.      the assigned order.
  4130.  
  4131.  
  4132. Example Program
  4133.      The following program removes the Resident Manager from memory.
  4134.  
  4135.      #include <stdio.h>
  4136.      #include <cas.h>
  4137.  
  4138.      main ()
  4139.      {
  4140.        int retval;
  4141.  
  4142.  
  4143.  
  4144.  
  4145.  
  4146.  
  4147.  
  4148.  
  4149.  
  4150.  
  4151.  
  4152.  
  4153.  
  4154.  
  4155.  
  4156. 4-42                        CASLIB:  C Library for CAS Developers
  4157.  
  4158.  
  4159.  
  4160.  
  4161.  
  4162.                                                              16H
  4163.                                         CASUnloadResidentManager
  4164.        retval = CASUnloadResidentManager();
  4165.        if (!retval) {
  4166.          printf("CAS successfully unloaded.\n");
  4167.        }
  4168.        else {
  4169.          printf("UnloadResidentManager failed,\n");
  4170.          printf("CAS error code is: 0X%X\n", -retval);
  4171.        }
  4172.      }
  4173.  
  4174.  
  4175.  
  4176.  
  4177.  
  4178.  
  4179.  
  4180.  
  4181.  
  4182.  
  4183.  
  4184.  
  4185.  
  4186.  
  4187.  
  4188.  
  4189.  
  4190.  
  4191.  
  4192.  
  4193.  
  4194.  
  4195.  
  4196.  
  4197.  
  4198.  
  4199.  
  4200.  
  4201.  
  4202.  
  4203.  
  4204.  
  4205.  
  4206.  
  4207.  
  4208.  
  4209.  
  4210.  
  4211.  
  4212.  
  4213.  
  4214.  
  4215.  
  4216.  
  4217.  
  4218.  
  4219.  
  4220.  
  4221.  
  4222. CASLIB:  C Library for CAS Developers                        4-43
  4223.  
  4224.  
  4225.  
  4226.  
  4227.  
  4228.  
  4229.  
  4230.  
  4231.  
  4232.  
  4233.                FAXLIB:  HIGH-LEVEL  LIBRARY
  4234.  
  4235.           5    FOR CAS DEVELOPERS
  4236.                FAXLIB contains the high-level functions that provide
  4237.                simplified management of events and error handling.  This
  4238.                chapter describes each function listed in alphabetical
  4239.                order.  The format of the function descriptions is as
  4240.                follows:
  4241.  
  4242.                ╖ Description of the function.
  4243.  
  4244.                ╖ Summary provides the syntax for each function.
  4245.  
  4246.                ╖ Parameters describes the parameters for each function.
  4247.  
  4248.                ╖ Errors provides error information.
  4249.  
  4250.                ╖ Return Value can be used to test for error conditions or
  4251.                  to provide the requested information.
  4252.  
  4253.                ╖ Remarks provides additional information on the function.
  4254.  
  4255.                ╖ See Also lists related functions.
  4256.  
  4257.                ╖ Example Program shows how the function is used.
  4258.  
  4259.  
  4260.  
  4261.           Compiling and Linking With FAXLIB
  4262.                To use functions from the FAXLIB library, applications must
  4263.                include the following files:
  4264.  
  4265.                ╖ CAS.H
  4266.                ╖ FAX.H
  4267.                ╖ FAXGLOB.H
  4268.                ╖ FAXDFLTS.H (for functions FAXSend and FAXSubmit only)
  4269.                ╖ FAXERROR.H (for function FAXError only)
  4270.  
  4271.                Link applications to the correct library for the memory
  4272.                model they are using.  For example, the following are the
  4273.                compile and link commands for an application called SAMPLE.C
  4274.                written for the small memory model:
  4275.  
  4276.                cl /c /AS sample.c
  4277.                link sample ,, NUL, SFAXLIB, SCASLIB;
  4278.  
  4279.  
  4280.  
  4281.  
  4282.  
  4283.  
  4284.  
  4285.  
  4286.  
  4287.  
  4288.           FAXLIB:  High-Level Library for CAS Developers                5-1
  4289.           5-1                FAXLIB:  High-Level Library for CAS Developers
  4290.  
  4291.  
  4292.  
  4293.  
  4294.  
  4295.  
  4296.  
  4297.                To use CL.EXE to both compile and link, type the following
  4298.                command:
  4299.  
  4300.                cl /AS sample.c /l SFAXLIB, SCASLIB
  4301.  
  4302.  
  4303.  
  4304.                NOTE:
  4305.                     The FAXLIB functions use some functions from CASLIB.
  4306.                     If you use FAXLIB functions, your application must be
  4307.                     linked to both FAXLIB and CASLIB.
  4308.  
  4309.  
  4310.  
  4311.           FAXLIB Functions Grouped by Operation
  4312.                The FAXLIB functions can be divided into three groups:
  4313.  
  4314.                ╖ Event Management
  4315.                ╖ Event and Queue Queries
  4316.                ╖ Error Handling
  4317.  
  4318.  
  4319.           Event Management
  4320.                These functions simplify event management by hiding all
  4321.                control file management operations in lower levels and
  4322.                providing common defaults for many communications options.
  4323.                For example, to send a fax or file, the application must
  4324.                specify the recipient's phone number, the file(s) to be
  4325.                sent, and when to send the file(s).  The FAXLIB function
  4326.                uses defaults for the remaining parameters.  These defaults
  4327.                can be predefined set or defined by the application.
  4328.  
  4329.                FAXCancelTask       Cancels a specified scheduled event.  If
  4330.                                    the event is in progress, it is aborted.
  4331.  
  4332.                FAXCopyECS          Copies all the information in an Event
  4333.                                    Control Structure to another structure.
  4334.  
  4335.                FAXFreeECS          Frees all the memory used by an Event
  4336.                                    Control Structure.
  4337.  
  4338.                FAXSend             Creates and submits a Send event to the
  4339.                                    Resident Manager.
  4340.  
  4341.                FAXSubmitTask       Creates and submits an event from the
  4342.                                    settings of Tasksettings (along with the
  4343.                                    where, what, and when parameters) to the
  4344.                                    Resident Manager.
  4345.  
  4346.  
  4347.  
  4348.  
  4349.  
  4350.  
  4351.  
  4352.  
  4353.  
  4354.           5-2                FAXLIB:  High-Level Library for CAS Developers
  4355.  
  4356.  
  4357.  
  4358.  
  4359.  
  4360.  
  4361.  
  4362.  
  4363.           Event and Queue Queries
  4364.                These functions search the Task, Receive, or Log queues for
  4365.                information about an event.
  4366.  
  4367.                FAXGetEventControlInfo                                   Gets that portion of information about
  4368.                                    an event that is in the control file's
  4369.                                    fixed-length part, the Event Control
  4370.                                    File (ECF) structure.
  4371.  
  4372.                FAXGetEventCover    Gets the cover page text of an event.
  4373.  
  4374.                FAXGetEventFileInfo Gets the File Transfer Records (FTRs)
  4375.                                    for an event.
  4376.  
  4377.  
  4378.           Error Handling
  4379.                This function returns information on errors.
  4380.  
  4381.                FAXError            Returns error or warning information on
  4382.                                    FAXLIB as well as CASLIB function calls.
  4383.  
  4384.  
  4385.  
  4386.  
  4387.  
  4388.  
  4389.  
  4390.  
  4391.  
  4392.  
  4393.  
  4394.  
  4395.  
  4396.  
  4397.  
  4398.  
  4399.  
  4400.  
  4401.  
  4402.  
  4403.  
  4404.  
  4405.  
  4406.  
  4407.  
  4408.  
  4409.  
  4410.  
  4411.  
  4412.  
  4413.  
  4414.  
  4415.  
  4416.  
  4417.  
  4418.  
  4419.  
  4420.           FAXLIB:  High-Level Library for CAS Developers                5-3
  4421.  
  4422.  
  4423.  
  4424.  
  4425.  
  4426.           FAXCancelTask
  4427.  
  4428.  
  4429.  
  4430.  
  4431.           Description
  4432.                Cancels a specified scheduled event.  If the event is in
  4433.                progress, it is aborted.
  4434.  
  4435.  
  4436.           Summary
  4437.                #include <cas.h>
  4438.                #include <fax.h>
  4439.  
  4440.                int FAXCancelTask (EventHandle);
  4441.  
  4442.  
  4443.           Input Parameter
  4444.                int EventHandle;    Event handle of the event to cancel.
  4445.                                    The functions FAXSend and FAXSubmitTask
  4446.                                    return this handle when they
  4447.                                    successfully submit an event.
  4448.  
  4449.  
  4450.           Output Parameter
  4451.                None.
  4452.  
  4453.  
  4454.           Errors
  4455.                If an error or warning condition occurs, FAXCancelTask sets
  4456.                the global variable FAXerrno.  For a listing of the FAXerrno
  4457.                numbers and associated messages, refer to FAXERROR.H.
  4458.  
  4459.  
  4460.           Return Value
  4461.                Returns the event handle if successful; otherwise, returns
  4462.                0.
  4463.  
  4464.  
  4465.           Remarks
  4466.                If the canceled event was pending at the time of the call,
  4467.                the function deletes the event's Control File.  If the event
  4468.                was executing at the time of the call, this function calls
  4469.                CASAbortCurrentEvent which aborts it.  CASAbortCurrentEvent
  4470.                does not delete the Control File but moves it to the Log
  4471.                Queue.
  4472.  
  4473.  
  4474.  
  4475.                NOTE:
  4476.                     A Receive event and a Log are not initiated by the
  4477.                     local application and so cannot be canceled by the
  4478.                     local application.
  4479.  
  4480.  
  4481.  
  4482.  
  4483.  
  4484.  
  4485.  
  4486.           5-4                FAXLIB:  High-Level Library for CAS Developers
  4487.  
  4488.  
  4489.  
  4490.  
  4491.  
  4492.                                                              FAXCancelTask
  4493.  
  4494.  
  4495.           Example Program
  4496.                The following program cancels the pending event.
  4497.  
  4498.                #include <stdio.h>
  4499.                #include <cas.h>
  4500.                #include <fax.h>
  4501.                #include <faxglob.h>
  4502.                #include <faxerror.h>
  4503.  
  4504.                main()
  4505.                {
  4506.                  int handle, ErrorClass;
  4507.                  BYTE queue = TASK_QUEUE;
  4508.                  char *msg;
  4509.  
  4510.                  handle = CASFindFirst(ANY_STATUS, SEARCH_FORWARD, queue);
  4511.                  if (handle > 0) {
  4512.                    handle = FAXCancelTask(handle);
  4513.                    if (handle) {
  4514.                      printf("The next send has been cancelled");
  4515.                    }
  4516.                    else {
  4517.                      msg = FAXError("CancelTask problem\n",
  4518.                                      NULL,
  4519.                                      &ErrorClass);
  4520.                      printf(msg);
  4521.                      free(msg);
  4522.                    }
  4523.                  }
  4524.                  else {
  4525.                    printf("Error occurred in CASFindFirst");
  4526.                  }
  4527.                }
  4528.  
  4529.  
  4530.  
  4531.  
  4532.  
  4533.  
  4534.  
  4535.  
  4536.  
  4537.  
  4538.  
  4539.  
  4540.  
  4541.  
  4542.  
  4543.  
  4544.  
  4545.  
  4546.  
  4547.  
  4548.  
  4549.  
  4550.  
  4551.  
  4552.           FAXLIB:  High-Level Library for CAS Developers                5-5
  4553.  
  4554.  
  4555.  
  4556.  
  4557.  
  4558.           FAXCopyECS
  4559.  
  4560.  
  4561.  
  4562.  
  4563.  
  4564.           Description
  4565.                Copies all the information in one Event Control Structure to
  4566.                another Event Control Structure.
  4567.  
  4568.  
  4569.           Summary
  4570.                #include <cas.h>
  4571.                #include <fax.h>
  4572.  
  4573.                ECS *FAXCopyECS (SourceECS, CopyECS);
  4574.  
  4575.  
  4576.           Input Parameters
  4577.                ECS *SourceECS;     Pointer to an Event Control Structure.
  4578.  
  4579.                ECS *CopyECS;       NULL or pointer to an Event Control
  4580.                                    Structure.
  4581.  
  4582.  
  4583.           Output Parameter
  4584.                ECS *CopyECS;       If CopyECS is NULL on input, this
  4585.                                    function allocates memory and copies the
  4586.                                    given Event Control Structure.  If not
  4587.                                    NULL on input, the Event Control
  4588.                                    Structure specified is filled with data
  4589.                                    identical to that in the *SourceECS.
  4590.  
  4591.  
  4592.           Errors
  4593.                If an error or warning condition occurs, FAXCopyECS sets the
  4594.                global variable FAXerrno.  For a listing of the FAXerrno
  4595.                numbers and associated messages, refer to FAXERROR.H.  If an
  4596.                error occurs, no information is copied and no memory is
  4597.                allocated.
  4598.  
  4599.  
  4600.           Return Value
  4601.                Returns a pointer to the copy structure if successful;
  4602.                otherwise, returns NULL.
  4603.  
  4604.  
  4605.           Remarks
  4606.                If CopyECS points to an Event Control Structure on input,
  4607.                the function copies the data from SourceECS into CopyECS.
  4608.                CopyECS and SourceECS must have an equal number of FTRLIST
  4609.                structures allocated.  CopyECS must have enough space
  4610.                allocated for the cover page text, if any.  When through
  4611.                with the structure, the application must free this memory.
  4612.  
  4613.  
  4614.  
  4615.  
  4616.  
  4617.  
  4618.           5-6                FAXLIB:  High-Level Library for CAS Developers
  4619.  
  4620.  
  4621.  
  4622.  
  4623.  
  4624.                                                                 FAXCopyECS
  4625.  
  4626.  
  4627.                FAXCopyECS is useful for making copies of the DefaultsECS
  4628.                and altering specific fields for use with FAXSubmitTask.
  4629.                This process allows submission of non-default events without
  4630.                altering the Toolkit defaults.
  4631.  
  4632.  
  4633.           See Also
  4634.                FAXSubmitTask, FAXFreeECS
  4635.  
  4636.  
  4637.           Example Program
  4638.                The following program makes a copy of the default event
  4639.                structure, sets the copy's destination name, phone number,
  4640.                and file list fields, and submits the event.
  4641.  
  4642.                #include <stdio.h>
  4643.                #include <cas.h>
  4644.                #include <fax.h>
  4645.                #include <faxglob.h>
  4646.                #include <faxdflts.h>
  4647.                #include <faxerror.h>
  4648.  
  4649.                CAS_DATE date = {1991, 1, 2};  /* January 2, 1991 */
  4650.  
  4651.                main()
  4652.                {
  4653.                  ECS *ecs;
  4654.                  int retval, ErrorClass;
  4655.                  char *errmsg;
  4656.  
  4657.                  ecs = FAXCopyECS(&DefaultsECS, NULL);
  4658.                  if (ecs) {
  4659.                    retval = FAXSubmitTask(ecs, "Lab fax", "9, 645-8468",
  4660.                                           NULL, &date, NULL);
  4661.                    if (retval > 0) {
  4662.                      printf("Event 0X%X successfully submitted.\n",
  4663.                retval);
  4664.                    }
  4665.                    else {
  4666.                      errmsg=FAXError("Problem submitting event.\n", NULL,
  4667.                                      &ErrorClass);
  4668.                      printf(errmsg);
  4669.                      free(errmsg);
  4670.                    }
  4671.                  }
  4672.                  else {
  4673.                    errmsg=FAXError("Problem copying defaults.\n", NULL,    
  4674.                                          &ErrorClass);
  4675.                    printf(errmsg);
  4676.                    free(errmsg);
  4677.                  }
  4678.                }
  4679.  
  4680.  
  4681.  
  4682.  
  4683.  
  4684.           FAXLIB:  High-Level Library for CAS Developers                5-7
  4685.  
  4686.  
  4687.  
  4688.  
  4689.  
  4690.           FAXError
  4691.  
  4692.  
  4693.  
  4694.  
  4695.  
  4696.           Description
  4697.                Returns error or warning information on FAXLIB as well as
  4698.                CASLIB function calls.
  4699.  
  4700.  
  4701.           Summary
  4702.                #include <cas.h>
  4703.                #include <fax.h>
  4704.                #include <faxerror.h>
  4705.  
  4706.                char * FAXError (MessageIn, MessageOut, ErrorClass);
  4707.  
  4708.  
  4709.           Input Parameters
  4710.                char *MessageIn;    Pointer to a message provided by the
  4711.                                    caller.  The function adds this message
  4712.                                    to the string it returns.  If no
  4713.                                    additional message is desired, set this
  4714.                                    value to NULL.
  4715.  
  4716.                char *MessageOut;   Pointer to a buffer to hold the returned
  4717.                                    error messages or NULL.  If MessageOut
  4718.                                    is set to NULL, FAXError allocates the
  4719.                                    memory it needs for the messages.
  4720.  
  4721.  
  4722.           Output Parameters
  4723.                char *MessageOut;   If non-NULL on entry, holds the returned
  4724.                                    error messages on exit.
  4725.  
  4726.                int *ErrorClass;    Pointer to the type of error.  Error
  4727.                                    classes are defined in CAS.H.
  4728.  
  4729.  
  4730.           Return Value
  4731.                Returns a pointer to the concatenated message.  If the
  4732.                caller provided a buffer for the message in MessageOut,
  4733.                FAXError returns a pointer to that buffer.  Strings are
  4734.                separated by the new-line character.  Returns NULL if an
  4735.                error occurred.
  4736.  
  4737.  
  4738.           Remarks
  4739.                This function concatenates up to three strings and returns a
  4740.                pointer to the result.  If the caller provides a message in
  4741.                MessageIn, the first string is that message.  If FAXerrno is
  4742.                non-zero, a second string is added from the FAXerrlist table
  4743.                indexed by FAXerrno.  If CASerrorcode is non-zero, a third
  4744.                string as well as the ErrorClass return parameter is
  4745.                obtained from the CASerrors table.  The error tables are
  4746.                defined in FAXERROR.H.
  4747.  
  4748.  
  4749.  
  4750.           5-8                FAXLIB:  High-Level Library for CAS Developers
  4751.  
  4752.  
  4753.  
  4754.  
  4755.  
  4756.                                                                    FAXError
  4757.  
  4758.  
  4759.                If MessageOut is non-NULL, it is assumed to point to a
  4760.                buffer large enough (3 * MSGLENGTH) to hold the maximum
  4761.                number of messages.  FAXError copies the messages into that
  4762.                buffer.  The caller must free up this memory.
  4763.  
  4764.                Although not in the parameter list, two external variables
  4765.                are important input to this function.  These are FAXerrno
  4766.                and CASerrorcode.
  4767.  
  4768.                When a FAXLIB function encounters an error or a warning
  4769.                condition, it sets FAXerrno to a positive non-zero value
  4770.                before returning.  If there is no error or warning, it sets
  4771.                FAXerrno to 0.  FAXError should be called immediately after
  4772.                any FAXLIB function that returns an error or warning, so no
  4773.                intervening FAXLIB function has the chance to reset
  4774.                FAXerrno.
  4775.  
  4776.                When a FAXLIB function receives an error return from a
  4777.                CASLIB function call, it sets CASerrorcode to the opposite
  4778.                (2's complement) of that return value, and sets FAXerrno to
  4779.                indicate which CASLIB function was in error.  The error may
  4780.                not be fatal.  The FAXLIB function may continue operation
  4781.                and return normally.  FAXLIB functions indicate error by
  4782.                returning 0 or NULL.
  4783.  
  4784.                An application can use FAXError to obtain information about
  4785.                an error return from one of the CASLIB functions.  To do
  4786.                this, set CASerrorcode to the opposite (2's complement) of
  4787.                the return value of the CASLIB function, set FAXerrno to the
  4788.                CAS function number, and call FAXError.
  4789.  
  4790.  
  4791.           See Also
  4792.                Every CASLIB and FAXLIB function can set error codes for
  4793.                which FAXError returns information.
  4794.  
  4795.  
  4796.           Example Program
  4797.                The following program scans the Log Queue for any events in
  4798.                an error condition and calls FAXError to retrieve the error
  4799.                information.
  4800.  
  4801.                #include <stdio.h>
  4802.                #include <stdlib.h>
  4803.                #include <cas.h>
  4804.                #include <fax.h>
  4805.                #include <faxglob.h>
  4806.                #include <faxerror.h>
  4807.  
  4808.                main()
  4809.                {
  4810.                  int handle, ErrorClass;
  4811.                  BYTE queue = LOG_QUEUE;
  4812.                  char *msg;
  4813.  
  4814.  
  4815.  
  4816.           FAXLIB:  High-Level Library for CAS Developers                5-9
  4817.  
  4818.  
  4819.  
  4820.  
  4821.  
  4822.           FAXError
  4823.  
  4824.  
  4825.                  ECF event, *retval;
  4826.  
  4827.                  handle = CASFindFirst(ANY_STATUS,
  4828.                                        SEARCH_FORWARD,
  4829.                                        queue);
  4830.                  if (handle > 0) {
  4831.                    while (1) {
  4832.                      retval = FAXGetEventControlInfo(handle,
  4833.                                                     &queue,
  4834.                                                     &event);
  4835.                      if (retval > 0) {
  4836.  
  4837.                        /* For every event in the log, check its status */
  4838.                        /* If status is negative, fetch and print err msg */
  4839.                        if (event.EventStatus < 0) {
  4840.                          CASerrorcode = -event.EventStatus;
  4841.                          msg = FAXError("Logged Event Error:\n",
  4842.                                         NULL,
  4843.                                         &ErrorClass);
  4844.                          printf(msg);
  4845.                          free(msg);
  4846.                        }
  4847.                      }
  4848.                      handle = CASFindNext(queue);
  4849.                      if (handle < 0) {
  4850.                        break;
  4851.                      }
  4852.                    }
  4853.                  }
  4854.                  else {
  4855.                    printf("No logged events");
  4856.                  }
  4857.                }
  4858.                
  4859.  
  4860.  
  4861.  
  4862.  
  4863.  
  4864.  
  4865.  
  4866.  
  4867.  
  4868.  
  4869.  
  4870.  
  4871.  
  4872.  
  4873.  
  4874.  
  4875.  
  4876.  
  4877.  
  4878.  
  4879.  
  4880.  
  4881.  
  4882.           5-10               FAXLIB:  High-Level Library for CAS Developers
  4883.  
  4884.  
  4885.  
  4886.  
  4887.  
  4888.                                                                  FAXFreeECS
  4889.  
  4890.  
  4891.  
  4892.  
  4893.           Description
  4894.                Frees all memory used by an Event Control Structure.
  4895.  
  4896.  
  4897.           Summary
  4898.                #include <cas.h>
  4899.                #include <fax.h>
  4900.  
  4901.                int FAXFreeECS (EventECS);
  4902.  
  4903.  
  4904.           Input Parameter
  4905.                ECS *EventECS; Pointer to an Event Control structure.  All
  4906.                               memory used by this structure must have been
  4907.                               allocated from conventional memory using the
  4908.                               standard C library or by the Toolkit function
  4909.                               FAXCopyECS.
  4910.  
  4911.  
  4912.           Output Parameter
  4913.                None.
  4914.  
  4915.  
  4916.           Errors
  4917.                If an error or warning condition occurs, FAXFreeECS sets the
  4918.                global variable FAXerrno.  For a listing of the FAXerrno
  4919.                numbers and associated messages, refer to FAXERROR.H.
  4920.  
  4921.  
  4922.           Return Value
  4923.                Returns FAIL only if the parameter EventECS is NULL.
  4924.                Otherwise, the function always returns SUCCESS.
  4925.  
  4926.  
  4927.           Remarks
  4928.                The EventECS must be in conventional memory.  Using this
  4929.                function to free data in expanded memory has unpredictable
  4930.                results.
  4931.  
  4932.  
  4933.           See Also
  4934.                FAXCopyECS
  4935.  
  4936.  
  4937.  
  4938.  
  4939.  
  4940.  
  4941.  
  4942.  
  4943.  
  4944.  
  4945.  
  4946.  
  4947.  
  4948.           FAXLIB:  High-Level Library for CAS Developers               5-11
  4949.  
  4950.  
  4951.  
  4952.  
  4953.  
  4954.           FAXFreeECS
  4955.  
  4956.  
  4957.           Example Program
  4958.                The following program makes a copy of the default event
  4959.                structure and frees the copy.
  4960.  
  4961.                #include <stdio.h>
  4962.                #include <string.h>
  4963.                #include <cas.h>
  4964.                #include <fax.h>
  4965.                #include <faxglob.h>
  4966.                #include <faxdflts.h>
  4967.                #include <faxerror.h>
  4968.  
  4969.                main()
  4970.                {
  4971.                  ECS *copy;
  4972.                  int retval, ErrorClass;
  4973.  
  4974.                  copy = FAXCopyECS(&DefaultsECS, NULL);
  4975.                  if (copy) {
  4976.                    if (FAXFreeECS(copy)) {
  4977.                      printf("Copied Event Control Structure freed");
  4978.                    }
  4979.                  }
  4980.                  else {
  4981.                    printf(FAXError("Problem copying defaults\n", NULL,
  4982.                                    &ErrorClass));
  4983.                  }
  4984.                }
  4985.  
  4986.  
  4987.  
  4988.  
  4989.  
  4990.  
  4991.  
  4992.  
  4993.  
  4994.  
  4995.  
  4996.  
  4997.  
  4998.  
  4999.  
  5000.  
  5001.  
  5002.  
  5003.  
  5004.  
  5005.  
  5006.  
  5007.  
  5008.  
  5009.  
  5010.  
  5011.  
  5012.  
  5013.  
  5014.           5-12               FAXLIB:  High-Level Library for CAS Developers
  5015.  
  5016.  
  5017.  
  5018.  
  5019.  
  5020.                                                     FAXGetEventControlInfo
  5021.  
  5022.  
  5023.  
  5024.  
  5025.           Description
  5026.                Gets that portion of information about an event that is in
  5027.                the control file's fixed-length part, the Event Control File
  5028.                (ECF) structure.
  5029.  
  5030.  
  5031.           Summary
  5032.                #include <cas.h>
  5033.                #include <fax.h>
  5034.  
  5035.                ECF *FAXGetEventControlInfo (EventHandle, queue, EventInfo);
  5036.  
  5037.  
  5038.           Input Parameters
  5039.                int EventHandle;    Event handle of an existing event.  The
  5040.                                    event may be pending, currently
  5041.                                    executing, or completed.
  5042.  
  5043.                BYTE *queue;        Pointer to the queue that the event is
  5044.                                    in, if known.  The queue constants are
  5045.                                    TASK_QUEUE, RECEIVE_QUEUE, and
  5046.                                    LOG_QUEUE.  If you do not know the queue
  5047.                                    holding the event, setting queue to
  5048.                                    UNKNOWN_QUEUE causes the function to
  5049.                                    search all the queues.
  5050.  
  5051.                ECF *EventInfo;     Pointer to an ECF structure or NULL.  If
  5052.                                    EventInfo points to an ECF structure on
  5053.                                    input, the function copies the ECF
  5054.                                    information into that structure.
  5055.                                    Otherwise (EventInfo is NULL) the
  5056.                                    function allocates an ECF structure,
  5057.                                    copies the information into it, and
  5058.                                    returns a pointer to that structure.
  5059.  
  5060.  
  5061.           Output Parameters
  5062.                BYTE *queue;        The queue where the event was found.  If
  5063.                                    the event was currently executing, queue
  5064.                                    is set to UNKNOWN_QUEUE.
  5065.  
  5066.                ECF *EventInfo;     If on input this pointed to an ECF
  5067.                                    structure, on return it contains
  5068.                                    information about the event specified.
  5069.                                    This structure, along with the output of
  5070.                                    the functions FAXGetEventCover and
  5071.                                    FAXGetEventFileInfo can be used to
  5072.                                    create an ECS structure.
  5073.  
  5074.  
  5075.  
  5076.  
  5077.  
  5078.  
  5079.  
  5080.           FAXLIB:  High-Level Library for CAS Developers               5-13
  5081.  
  5082.  
  5083.  
  5084.  
  5085.  
  5086.           FAXGetEventControlInfo
  5087.  
  5088.  
  5089.           Return Value
  5090.                Returns a pointer to the ECF structure retrieved if
  5091.                successful, otherwise, returns NULL.
  5092.  
  5093.  
  5094.           Errors
  5095.                If an error or warning condition occurs,
  5096.                FAXGetEventControlInfo sets the global variable FAXerrno.
  5097.                For a listing of the FAXerrno numbers and associated
  5098.                messages, refer to FAXERROR.H.
  5099.  
  5100.  
  5101.           Remarks
  5102.                If you specify the queue, FAXGetEventControlInfo uses
  5103.                CASOpenFile on the specified event in that queue and reads
  5104.                the ECF information for that event.  If you do not specify
  5105.                the queue (queue is UNKNOWN_QUEUE), FAXGetEventControlInfo
  5106.                calls CASFindFirst and CASFindNext to search all the queues
  5107.                until it finds the file associated with the specified event.
  5108.                It then opens that file and reads the ECF information.  To
  5109.                obtain information about the current event, applications
  5110.                should call CASGetCurrentEventStatus.
  5111.  
  5112.  
  5113.           See Also
  5114.                CASFindFirst, CASFindNext, FAXGetEventCover,
  5115.                FAXGetEventFileInfo
  5116.  
  5117.  
  5118.           Example Program
  5119.                The following program retrieves information for the oldest
  5120.                event in the Log Queue and prints out the event type.
  5121.  
  5122.                #include <stdio.h>
  5123.                #include <string.h>
  5124.                #include <cas.h>
  5125.                #include <fax.h>
  5126.                #include <faxglob.h>
  5127.                #include <faxerror.h>
  5128.  
  5129.                main()
  5130.                {
  5131.                  ECF info, *retval;
  5132.                  int handle,ErrorClass;
  5133.                  BYTE queue = LOG_QUEUE;
  5134.                  char *msg;
  5135.  
  5136.                  handle = CASFindFirst(ANY_STATUS, SEARCH_FORWARD, queue);
  5137.                  if (handle > 0) {
  5138.                    retval = FAXGetEventControlInfo(handle, &queue, &info);
  5139.                    if (retval) {
  5140.                      printf("The oldest logged event is a ");
  5141.                      switch (info.EventType) {
  5142.                        case SEND:
  5143.  
  5144.  
  5145.  
  5146.           5-14               FAXLIB:  High-Level Library for CAS Developers
  5147.  
  5148.  
  5149.  
  5150.  
  5151.  
  5152.                                                     FAXGetEventControlInfo
  5153.  
  5154.  
  5155.                          printf("SEND");        break;
  5156.                        case RECEIVE:
  5157.                          printf("RECEIVE");     break;
  5158.                        case POLLED_SEND:
  5159.                          printf("POLLED_SEND"); break;
  5160.                        case POLLED_RECEIVE:
  5161.                          printf("POLLED_RECEIVE");
  5162.                      }
  5163.                    }
  5164.                    else {
  5165.                      msg = FAXError("GetEventInfo problem\n",
  5166.                                      NULL, &ErrorClass);
  5167.                      printf(msg);
  5168.                      free(msg);
  5169.                    }
  5170.                  }
  5171.                  else {
  5172.                    printf("No events in Log Queue");
  5173.                  }
  5174.                }
  5175.  
  5176.  
  5177.  
  5178.  
  5179.  
  5180.  
  5181.  
  5182.  
  5183.  
  5184.  
  5185.  
  5186.  
  5187.  
  5188.  
  5189.  
  5190.  
  5191.  
  5192.  
  5193.  
  5194.  
  5195.  
  5196.  
  5197.  
  5198.  
  5199.  
  5200.  
  5201.  
  5202.  
  5203.  
  5204.  
  5205.  
  5206.  
  5207.  
  5208.  
  5209.  
  5210.  
  5211.  
  5212.           FAXLIB:  High-Level Library for CAS Developers               5-15
  5213.  
  5214.  
  5215.  
  5216.  
  5217.  
  5218.           FAXGetEventCover
  5219.  
  5220.  
  5221.  
  5222.  
  5223.           Description
  5224.                Gets the cover page text of an event.
  5225.  
  5226.  
  5227.           Summary
  5228.                #include <cas.h>
  5229.                #include <fax.h>
  5230.  
  5231.                char *FAXGetEventCover (EventHandle, queue, CoverPtr);
  5232.  
  5233.  
  5234.           Input Parameters
  5235.                int EventHandle;    Event handle of an existing event.
  5236.  
  5237.                BYTE *queue;        Pointer to the queue that the event is
  5238.                                    in, if known.  The queue constants are
  5239.                                    TASK_QUEUE, RECEIVE_QUEUE, and
  5240.                                    LOG_QUEUE.  If the queue holding the
  5241.                                    event is not known, setting queue to
  5242.                                    UNKNOWN_QUEUE causes the function to
  5243.                                    search all the queues.
  5244.  
  5245.                char *CoverPtr;     Pointer to the buffer for the cover page
  5246.                                    text or NULL.
  5247.  
  5248.  
  5249.           Output Parameters
  5250.                BYTE *queue;        The queue where the event was found.
  5251.  
  5252.                char *CoverPtr;     If not NULL on input, this buffer
  5253.                                    contains the text of the cover page.
  5254.  
  5255.  
  5256.           Errors
  5257.                If an error or warning condition occurs, FAXGetEventCover
  5258.                sets the global variable FAXerrno.  For a listing of the
  5259.                FAXerrno numbers and associated messages, refer to
  5260.                FAXERROR.H.
  5261.  
  5262.  
  5263.           Return Value
  5264.                Returns a pointer to the cover page text read; returns NULL
  5265.                if an error occurred.
  5266.  
  5267.  
  5268.  
  5269.  
  5270.  
  5271.  
  5272.  
  5273.  
  5274.  
  5275.  
  5276.  
  5277.  
  5278.           5-16               FAXLIB:  High-Level Library for CAS Developers
  5279.  
  5280.  
  5281.  
  5282.  
  5283.  
  5284.                                                           FAXGetEventCover
  5285.  
  5286.  
  5287.           Remarks
  5288.                If you specify the queue, the function calls CASOpenFile to
  5289.                open the specified event in that queue.  If you do not
  5290.                specify the queue (queue is UNKNOWN_QUEUE), the function
  5291.                searches all the queues until it finds the specified event
  5292.                file.  If CoverPtr is not NULL, it is assumed to point to
  5293.                enough space to hold the cover page text.  The function
  5294.                reads the cover text into that buffer and returns its
  5295.                pointer.  If CoverPtr is NULL, the function allocates the
  5296.                memory itself, reads the cover page text into that memory,
  5297.                and returns its pointer.  The caller must free up this
  5298.                memory.
  5299.  
  5300.                If the caller lets the function allocate the memory for the
  5301.                CoverPtr buffer, it does not have to know how large the
  5302.                cover page is.  The function finds this information from the
  5303.                event control information in the file and allocates the
  5304.                needed space itself.  If the caller provides the buffer, the
  5305.                buffer must be large enough to store the information without
  5306.                overwriting other data.
  5307.  
  5308.                This function cannot retrieve an event's cover page text if
  5309.                the event is currently executing.
  5310.  
  5311.  
  5312.           See Also
  5313.                CASFindFirst, CASFindNext, FAXGetEventControlInfo,
  5314.                FAXGetEventFileInfo
  5315.  
  5316.  
  5317.           Example Program
  5318.                The following program retrieves and displays the cover page
  5319.                text for the last occurring event.
  5320.  
  5321.                #include <stdio.h>
  5322.                #include <stdlib.h>
  5323.                #include <malloc.h>
  5324.                #include <cas.h>
  5325.                #include <fax.h>
  5326.                #include <faxglob.h>
  5327.                #include <faxerror.h>
  5328.  
  5329.                main()
  5330.                {
  5331.                  int handle,ErrorClass;
  5332.                  BYTE queue = TASK_QUEUE;
  5333.                  char *cover, *msg;
  5334.  
  5335.  
  5336.  
  5337.  
  5338.  
  5339.  
  5340.  
  5341.  
  5342.  
  5343.  
  5344.           FAXLIB:  High-Level Library for CAS Developers               5-17
  5345.  
  5346.  
  5347.  
  5348.  
  5349.  
  5350.           FAXGetEventCover
  5351.  
  5352.  
  5353.                  handle = CASFindFirst(ANY_STATUS, SEARCH_BACKWARD, queue);
  5354.                  if (handle > 0) {
  5355.                    cover = FAXGetEventCover(handle, &queue, NULL);
  5356.                    if (cover) {
  5357.                      printf("cover for most future send is:\n%s",
  5358.                             cover);
  5359.                      free(cover);
  5360.                    }
  5361.                    else {
  5362.                      msg = FAXError("GetEventCover problem\n", NULL,       
  5363.                                       &ErrorClass);
  5364.                      printf(msg);
  5365.                      free(msg);
  5366.                    }
  5367.                  }
  5368.                  else {
  5369.                    printf("No pending events");
  5370.                  }
  5371.                }
  5372.  
  5373.  
  5374.  
  5375.  
  5376.  
  5377.  
  5378.  
  5379.  
  5380.  
  5381.  
  5382.  
  5383.  
  5384.  
  5385.  
  5386.  
  5387.  
  5388.  
  5389.  
  5390.  
  5391.  
  5392.  
  5393.  
  5394.  
  5395.  
  5396.  
  5397.  
  5398.  
  5399.  
  5400.  
  5401.  
  5402.  
  5403.  
  5404.  
  5405.  
  5406.  
  5407.  
  5408.  
  5409.  
  5410.           5-18               FAXLIB:  High-Level Library for CAS Developers
  5411.  
  5412.  
  5413.  
  5414.  
  5415.  
  5416.                                                        FAXGetEventFileInfo
  5417.  
  5418.  
  5419.  
  5420.  
  5421.           Description
  5422.                Gets the File Transfer Records (FTRs) for an event.
  5423.  
  5424.  
  5425.           Summary
  5426.                #include <cas.h>
  5427.                #include <fax.h>
  5428.  
  5429.                FTRLIST * FAXGetEventFileInfo (EventHandle, queue, FTRs,
  5430.                                               WhichFTRFirst, HowManyFTRS);
  5431.  
  5432.  
  5433.           Input Parameters
  5434.                EventHandle;        Event handle of an existing event.
  5435.  
  5436.                BYTE *queue;        Pointer to the queue that the event is
  5437.                                    in, if known.  The queue constants are
  5438.                                    TASK_QUEUE, RECEIVE_QUEUE, and
  5439.                                    LOG_QUEUE.  If you do not know the queue
  5440.                                    holding the event, setting queue to
  5441.                                    UNKNOWN_QUEUE causes the function to
  5442.                                    search all the queues.
  5443.  
  5444.                FTRLIST *FTRs;      Pointer to a linked list of one or more
  5445.                                    FTR structures or NULL.
  5446.  
  5447.                int WhichFTRFirst;  Which FTR in the given event to retrieve
  5448.                                    first.  (The first FTR is number 0.)
  5449.  
  5450.                int *HowManyFTRs;   Pointer to the number of FTR(s) to
  5451.                                    retrieve or 0 for all of them starting
  5452.                                    with WhichFTRFirst.
  5453.  
  5454.  
  5455.           Output Parameters
  5456.                BYTE *queue;        The queue where the event was found.
  5457.  
  5458.                FTRLIST *FTRs;      If FTRs was not NULL on entry, on return
  5459.                                    the list it pointed to contains the
  5460.                                    information for the FTRs requested.
  5461.  
  5462.                int *HowManyFTRs;   How many FTR(s) were actually retrieved.
  5463.                                    This may be fewer than the number
  5464.                                    requested.
  5465.  
  5466.  
  5467.           Errors
  5468.                If an error or warning condition occurs, FAXGetEventFileInfo
  5469.                sets the global variable FAXerrno.  For a listing of the
  5470.                FAXerrno numbers and associated messages, refer to
  5471.                FAXERROR.H.
  5472.  
  5473.  
  5474.  
  5475.  
  5476.           FAXLIB:  High-Level Library for CAS Developers               5-19
  5477.  
  5478.  
  5479.  
  5480.  
  5481.  
  5482.           FAXGetEventFileInfo
  5483.  
  5484.  
  5485.           Return Value
  5486.                Returns a pointer to the list of FTR(s) retrieved if
  5487.                successful; otherwise, returns NULL.  If the caller
  5488.                allocated a list and passed its pointer as the parameter
  5489.                FTRs, then this pointer is returned.  If the caller passed
  5490.                NULL for the parameter FTRs, then the function allocates
  5491.                memory for the list and returns a pointer to the first
  5492.                structure in that list.  The caller must free up this
  5493.                memory.
  5494.  
  5495.  
  5496.           Remarks
  5497.                If you specify the queue, the function calls CASOpenFile on
  5498.                the specified event in that queue.  If you do not specify
  5499.                the queue (queue is UNKNOWN_QUEUE), the function calls
  5500.                CASFindFirst and CASFindNext to search all the queues in
  5501.                turn until it finds the file associated with the specified
  5502.                event.  It then opens that ECF and finds the information on
  5503.                the FTR(s) requested.
  5504.  
  5505.                If FTRs is NULL, the function allocates the memory needed
  5506.                for HowManyFTRs structures.
  5507.  
  5508.                If FTRs is not NULL, it is assumed to point to a list of
  5509.                structures.  In this case the caller must make sure that
  5510.                this list contains at least HowManyFTRs structures.
  5511.  
  5512.                The function attempts to read HowManyFTRs File Transfer
  5513.                Records from the event file, starting at WhichFTRFirst.  If
  5514.                there is a difference between the number designated and the
  5515.                number read, the function sets HowManyFTRs to the number
  5516.                read.
  5517.  
  5518.                If the event is currently executing, this function cannot
  5519.                retrieve the event's file information.
  5520.  
  5521.  
  5522.  
  5523.                NOTE:
  5524.                     Do not use this function for getting the names of
  5525.                     received files to open, move, or delete them.  For
  5526.                     these activities, use CASOpenFile, CASMoveReceivedFile,
  5527.                     CASDeleteFile, and CASDeleteAllFiles.  Refer to the
  5528.                     appropriate reference page for additional information
  5529.                     on these functions.
  5530.  
  5531.  
  5532.           See Also
  5533.                CASFindFirst, CASFindNext, FAXGetEventControlInfo,
  5534.                FAXGetEventCover
  5535.  
  5536.  
  5537.  
  5538.  
  5539.  
  5540.  
  5541.  
  5542.           5-20               FAXLIB:  High-Level Library for CAS Developers
  5543.  
  5544.  
  5545.  
  5546.  
  5547.  
  5548.                                                        FAXGetEventFileInfo
  5549.  
  5550.  
  5551.           Example Program
  5552.                The following program retrieves the file information
  5553.                structure for the first file to be sent in a pending event.
  5554.  
  5555.                #include <stdio.h>
  5556.                #include <stdlib.h>
  5557.                #include <malloc.h>
  5558.                #include <cas.h>
  5559.                #include <fax.h>
  5560.                #include <faxglob.h>
  5561.                #include <faxerror.h>
  5562.  
  5563.                main()
  5564.                {
  5565.                  FTRLIST ftr, *retval;
  5566.                  int handle, ErrorClass;
  5567.                  BYTE queue = TASK_QUEUE;
  5568.                  char *msg;
  5569.                  int how_many = 1;
  5570.  
  5571.                  handle = CASFindFirst(ANY_STATUS,
  5572.                                        SEARCH_FORWARD,
  5573.                                        queue);
  5574.                  if (handle > 0) {
  5575.                    retval = FAXGetEventFileInfo(handle,
  5576.                                                 &queue,
  5577.                                                 &ftr,
  5578.                                                 0,
  5579.                                                 &how_many);
  5580.                    if (retval && (how_many == 1)) {
  5581.                      printf("The file that will be sent is: %s",
  5582.                             ftr.OneFTR.FileName);
  5583.                    }
  5584.                    else {
  5585.                      msg = FAXError("GetEventFileInfo problem\n",
  5586.                                      NULL,
  5587.                                      &ErrorClass);
  5588.                      printf(msg);
  5589.                      free(msg);
  5590.                    }
  5591.                  }
  5592.                  else {
  5593.                    printf("No pending events");
  5594.                  }
  5595.                }
  5596.  
  5597.  
  5598.  
  5599.  
  5600.  
  5601.  
  5602.  
  5603.  
  5604.  
  5605.  
  5606.  
  5607.  
  5608.           FAXLIB:  High-Level Library for CAS Developers               5-21
  5609.  
  5610.  
  5611.  
  5612.  
  5613.  
  5614.           FAXSend
  5615.  
  5616.  
  5617.  
  5618.  
  5619.           Description
  5620.                Creates and submits a Send event to the Resident Manager.
  5621.  
  5622.  
  5623.           Summary
  5624.                #include <cas.h>
  5625.                #include <fax.h>
  5626.                #include <faxdflts.h>
  5627.  
  5628.                int FAXSend (to, PhoneNumber, files, date, time);
  5629.  
  5630.  
  5631.           Input Parameters
  5632.                char *to;           NULL or pointer to the name of the
  5633.                                    destination.  For fax transmissions,
  5634.                                    this name is printed after "to:" at the
  5635.                                    top of each page.
  5636.  
  5637.                char *PhoneNumber;  NULL or pointer to a phone number
  5638.                                    following the CAS phone number
  5639.                                    specification.
  5640.  
  5641.                FILELIST *files;    NULL or pointer to one or more files to
  5642.                                    send, as a linked list of filenames and
  5643.                                    file types.
  5644.  
  5645.                CAS_DATE *date;     NULL or pointer to a structure
  5646.                                    containing the year, month, and day for
  5647.                                    the event to execute.
  5648.  
  5649.                CAS_TIME *time;     NULL or pointer to a structure
  5650.                                    containing the hour, minute, and second
  5651.                                    for the event to execute.
  5652.  
  5653.  
  5654.           Output Parameter
  5655.                None.
  5656.  
  5657.  
  5658.           Return Value
  5659.                Returns the event handle if successful; otherwise, returns
  5660.                0.
  5661.  
  5662.  
  5663.           Errors
  5664.                If an error or warning condition occurs, FAXSend sets the
  5665.                global variable FAXerrno.  For a listing of the FAXerrno
  5666.                numbers and associated messages, refer to FAXERROR.H.
  5667.  
  5668.  
  5669.  
  5670.  
  5671.  
  5672.  
  5673.  
  5674.           5-22               FAXLIB:  High-Level Library for CAS Developers
  5675.  
  5676.  
  5677.  
  5678.  
  5679.  
  5680.                                                                    FAXSend
  5681.  
  5682.  
  5683.           Remarks
  5684.                Using the parameters along with values in the DefaultsECS
  5685.                structure, this function submits the event to the Resident
  5686.                Manager.  For any of the parameters that are set to NULL,
  5687.                the FAXSend function uses the values of the corresponding
  5688.                fields in the DefaultsECS.
  5689.  
  5690.                To change the defaults from their predefined values, assign
  5691.                the desired values to the fields of the DefaultsECS
  5692.                structure.  Those new values are the defaults for the rest
  5693.                of the current run of the application.
  5694.  
  5695.                To change fields in the DefaultsECS structure to the
  5696.                original defaults, either change the fields directly to the
  5697.                original settings as defined in FAXDFLTS.H or make a copy of
  5698.                the defaults with FAXCopyECS before changing the fields.
  5699.  
  5700.  
  5701.  
  5702.                NOTE:
  5703.                     Setting the time earlier than the current time will
  5704.                     cause the event to execute immediately if the date is
  5705.                     set to the current date.  Therefore, Intel recommends
  5706.                     that you change the date before you change the time or
  5707.                     you may accidentally send an event before you intend
  5708.                     to.
  5709.  
  5710.                     Setting the date and time to all zeroes causes the
  5711.                     event to execute immediately.
  5712.  
  5713.  
  5714.           See Also
  5715.                FAXSubmitTask, FAXCopyECS
  5716.  
  5717.  
  5718.           Program Example
  5719.                The following program sends two ASCII files to a fax machine
  5720.                on January 2, 1991.
  5721.  
  5722.                #include <stdio.h>
  5723.                #include <cas.h>
  5724.                #include <fax.h>
  5725.                #include <faxglob.h>
  5726.                #include <faxdflts.h>
  5727.                #include <faxerror.h>
  5728.  
  5729.                CAS_DATE date = {1991, 1, 2};
  5730.                CAS_TIME time = {0, 0, 0};
  5731.                FILELIST file2 = {"c:\\autoexec.bat",
  5732.                                  ASCII,
  5733.                                  NULL},
  5734.                         file1 = {"c:\\config.sys",
  5735.                                  ASCII,
  5736.                                  &file2};
  5737.  
  5738.  
  5739.  
  5740.           FAXLIB:  High-Level Library for CAS Developers               5-23
  5741.  
  5742.  
  5743.  
  5744.  
  5745.  
  5746.           FAXSend
  5747.  
  5748.  
  5749.                char *errmsg;
  5750.  
  5751.                main()
  5752.                {
  5753.                  int retval, ErrorClass;
  5754.  
  5755.                  retval = FAXSend("Lab fax", "9, 645-8468", &file1,
  5756.                                   &date, &time);
  5757.                  if (retval > 0) {
  5758.                    printf("Event 0X%X successfully submitted.", retval);
  5759.                  }
  5760.                  else {
  5761.                    errmsg=FAXError("Problem submitting event\n", NULL,     
  5762.                                    &ErrorClass);
  5763.                    printf(errmsg);
  5764.                    free(errmsg);
  5765.                  }
  5766.                }
  5767.  
  5768.  
  5769.  
  5770.  
  5771.  
  5772.  
  5773.  
  5774.  
  5775.  
  5776.  
  5777.  
  5778.  
  5779.  
  5780.  
  5781.  
  5782.  
  5783.  
  5784.  
  5785.  
  5786.  
  5787.  
  5788.  
  5789.  
  5790.  
  5791.  
  5792.  
  5793.  
  5794.  
  5795.  
  5796.  
  5797.  
  5798.  
  5799.  
  5800.  
  5801.  
  5802.  
  5803.  
  5804.  
  5805.  
  5806.           5-24               FAXLIB:  High-Level Library for CAS Developers
  5807.  
  5808.  
  5809.  
  5810.  
  5811.  
  5812.                                                              FAXSubmitTask
  5813.  
  5814.  
  5815.  
  5816.  
  5817.           Description
  5818.                Creates and submits an event from the settings of
  5819.                Tasksettings along with the where, what, and when parameters
  5820.                to the Resident Manager.
  5821.  
  5822.  
  5823.           Summary
  5824.                #include <cas.h>
  5825.                #include <fax.h>
  5826.                #include <faxdflts.h>
  5827.  
  5828.                int FAXSubmitTask (TaskSettings, to, PhoneNumber, files,
  5829.                date, time);
  5830.  
  5831.  
  5832.           Input Parameters
  5833.                ECS *TaskSettings;  Pointer to an Event Control Structure
  5834.                                    (ECS) containing all the information
  5835.                                    needed for an event not provided by the
  5836.                                    other parameters.  If any of the
  5837.                                    following pointer parameters are set to
  5838.                                    NULL, the values in the corresponding
  5839.                                    fields of this structure are used.
  5840.  
  5841.                char *to;           NULL or pointer to name of the
  5842.                                    destination.  For fax transmissions,
  5843.                                    this name is printed after "to:" at the
  5844.                                    top of each page.
  5845.  
  5846.                char *PhoneNumber;                                     NULL or pointer to a phone number
  5847.                                    following the CAS phone number
  5848.                                    specification.
  5849.  
  5850.                FILELIST *files;    NULL or pointer to one or more files to
  5851.                                    send, as a linked list of filenames and
  5852.                                    file types.
  5853.  
  5854.                CAS_DATE *date;     NULL or pointer to a structure
  5855.                                    containing the year, month, and day for
  5856.                                    the event to execute.
  5857.  
  5858.                CAS_TIME *time;     NULL or pointer to a structure
  5859.                                    containing the hour, minute, and second
  5860.                                    for the event to execute.
  5861.  
  5862.  
  5863.           Output Parameter
  5864.                ECS *TaskSettings;  If any of the other parameters were set
  5865.                                    (non-NULL), those values replace the
  5866.                                    corresponding fields of this ECS.
  5867.  
  5868.  
  5869.  
  5870.  
  5871.  
  5872.           FAXLIB:  High-Level Library for CAS Developers               5-25
  5873.  
  5874.  
  5875.  
  5876.  
  5877.  
  5878.           FAXSubmitTask
  5879.  
  5880.  
  5881.           Return Value
  5882.                Returns the event handle if successful; otherwise, returns
  5883.                0.
  5884.  
  5885.  
  5886.           Errors
  5887.                If an error or warning condition occurs, FAXSubmitTask sets
  5888.                the global variable FAXerrno.  For a listing of the FAXerrno
  5889.                numbers and associated messages, refer to FAXERROR.H.
  5890.  
  5891.  
  5892.           Remarks
  5893.                Creates an ECF from the settings of the TaskSettings along
  5894.                with the other parameters that are not NULL and submits the
  5895.                event to the Resident Manager.  Setting the parameters to a
  5896.                non-NULL value changes the values of the corresponding field
  5897.                in TaskSettings.
  5898.  
  5899.                To create an ECS with all the fields already filled in with
  5900.                valid values, use FAXCopyECS with the DefaultsECS as the
  5901.                source.
  5902.  
  5903.  
  5904.  
  5905.                NOTE:
  5906.                     Setting the time earlier than the current time will
  5907.                     cause the event to execute immediately if the date is
  5908.                     set to the current date.  Therefore, Intel recommends
  5909.                     that you change the date before you change the time or
  5910.                     you may accidentally send an event before you intend
  5911.                     to.
  5912.  
  5913.                     Setting the date and time to all zeroes causes the
  5914.                     event to execute immediately.
  5915.  
  5916.  
  5917.           See Also
  5918.                FAXSend, FAXCopyECS
  5919.  
  5920.  
  5921.           Example Program
  5922.                The following program sets the destination phone number, the
  5923.                to field, and the transmission date (January 2, 1991) of the
  5924.                default event structure and submits the event.
  5925.  
  5926.                #include <stdio.h>
  5927.                #include <cas.h>
  5928.                #include <fax.h>
  5929.                #include <faxglob.h>
  5930.                #include <faxdflts.h>
  5931.                #include <faxerror.h>
  5932.  
  5933.                CAS_DATE date = {1991, 1, 2};
  5934.  
  5935.  
  5936.  
  5937.  
  5938.           5-26               FAXLIB:  High-Level Library for CAS Developers
  5939.  
  5940.  
  5941.  
  5942.  
  5943.  
  5944.                                                              FAXSubmitTask
  5945.  
  5946.  
  5947.                main()
  5948.                {
  5949.                  int retval, ErrorClass;
  5950.                  char *errmsg;
  5951.  
  5952.                  retval = FAXSubmitTask(&DefaultsECS, "Lab fax", "9, 645-  
  5953.                                         8468", NULL, &date, NULL);
  5954.                  if (retval > 0) {
  5955.                    printf("Event 0X%X successfully submitted.", retval);
  5956.                  }
  5957.                  else {
  5958.                    errmsg=FAXError("Problem submitting event\n", NULL,     
  5959.                                     &ErrorClass);
  5960.                    printf(errmsg);
  5961.                    free(errmsg);
  5962.                  }
  5963.                }
  5964.                
  5965.  
  5966.  
  5967.  
  5968.  
  5969.  
  5970.  
  5971.  
  5972.  
  5973.  
  5974.  
  5975.  
  5976.  
  5977.  
  5978.  
  5979.  
  5980.  
  5981.  
  5982.  
  5983.  
  5984.  
  5985.  
  5986.  
  5987.  
  5988.  
  5989.  
  5990.  
  5991.  
  5992.  
  5993.  
  5994.  
  5995.  
  5996.  
  5997.  
  5998.  
  5999.  
  6000.  
  6001.  
  6002.  
  6003.  
  6004.           FAXLIB:  High-Level Library for CAS Developers               5-27
  6005.  
  6006.  
  6007.  
  6008.      PBLIB:  LIBRARY FOR
  6009.  
  6010. 6    PHONEBOOK MANAGEMENT
  6011.  
  6012.      PBLIB contains the phonebook functions.  While the Intel phonebook
  6013.      format is described in the DCA/Intel Communicating Applications
  6014.      Specification, it is not officially part of the specification.  The
  6015.      Intel phonebook format is used by Intel's application software.  The
  6016.      Intel phonebook format may or may not be compatible with phonebook
  6017.      formats used by other CAS compatible boards.  PBLIB uses the Intel
  6018.      phonebook format described in the DCA/Intel Communicating Applications
  6019.      Specification.
  6020.  
  6021.  
  6022.  
  6023.      NOTE:
  6024.           Be advised that using PBLIB may result in creating phonebooks
  6025.           that are compatible only with Intel phonebooks.
  6026.  
  6027.      This chapter describes the phonebook functions which are listed in
  6028.      alphabetical order.  The format of the function descriptions is as
  6029.      follows:
  6030.  
  6031.      ╖ Description of the function.
  6032.  
  6033.      ╖ Summary provides the syntax for each function.
  6034.  
  6035.      ╖ Parameters describes the parameters for each function.
  6036.  
  6037.      ╖ Errors provides error information.
  6038.  
  6039.      ╖ Return Value can be used to test for error conditions or to provide
  6040.        the information returned.
  6041.  
  6042.      ╖ Remarks provides additional information on the function.
  6043.  
  6044.      ╖ See Also lists related functions.
  6045.  
  6046.      ╖ Example Program shows how the function is used.
  6047.  
  6048.  
  6049.  
  6050.      NOTE:
  6051.           To understand the concepts and terms used in this chapter, you
  6052.           must be familiar with the DCA/Intel Communication Applications
  6053.           Specification information on the Intel phonebook format described
  6054.           in that document.
  6055.  
  6056.  
  6057.  
  6058.  
  6059.  
  6060.  
  6061.  
  6062.  
  6063.  
  6064.  
  6065.  
  6066.  
  6067.  
  6068.  
  6069.  
  6070. PBLIB:  Library For Phonebook Management                      6-1
  6071. 6-1                      PBLIB:  Library For Phonebook Management
  6072.  
  6073.  
  6074. Compiling and Linking With PBLIB
  6075.      To use functions from the PBLIB library, applications must include the
  6076.      following files:
  6077.  
  6078.      ╖ PHONEBK.H
  6079.      ╖ PBDFLT.H
  6080.      ╖ PBGLOBAL.H
  6081.      ╖ PBERROR.H
  6082.  
  6083.      Link applications to the correct library for the memory model they are
  6084.      using.  For example, the following are the compile and link commands
  6085.      for an application called SAMPLE.C written for the small memory model:
  6086.  
  6087.      cl /c /AS sample.c
  6088.      link sample ,, NUL, SPBLIB;
  6089.  
  6090.      To use CL.EXE to both compile and link, type the following command:
  6091.  
  6092.      cl /AS sample.c /l SPBLIB
  6093.  
  6094.  
  6095.  
  6096. Phonebook Functions Grouped by Operation
  6097.      Phonebooks are databases that CAS applications can use to make event
  6098.      generation easier for end-users.  The phonebook functions provide an
  6099.      interface to phonebook files which have the format described in the
  6100.      DCA/Intel Communicating Applications Specification.
  6101.  
  6102.      The phonebook support functions can be divided into three groups:
  6103.  
  6104.      ╖ General management
  6105.      ╖ Entry queries
  6106.      ╖ Entry modification
  6107.  
  6108.  
  6109. General Management
  6110.      These functions let you manage phonebooks including creating and
  6111.      opening a phonebook.
  6112.  
  6113.      PbBufferOffsets     Sets up the phonebook structure's buffer for all
  6114.                          phonebook entry queries and modification.
  6115.  
  6116.      PbCreatePhonebook   Creates a phonebook file consisting only of a
  6117.                          header and 0 entries.
  6118.  
  6119.      PbGarbageCollect    Eliminates unused space in a phonebook file.
  6120.  
  6121.      PbOpenPhonebook     Opens an existing phonebook file for query or
  6122.                          modification.
  6123.  
  6124.  
  6125. Entry Queries
  6126.      These functions look up pieces of information on specified entries.
  6127.  
  6128.      PbFindFirstOrNext   Gets the first or the next entry whose name
  6129.                          matches a given string specification, including
  6130.                          wildcards.
  6131.  
  6132.      PbFreePBE           Frees the memory used by a phonebook entry
  6133.                          structure.
  6134.  
  6135.  
  6136. 6-2                      PBLIB:  Library For Phonebook Management
  6137.  
  6138.  
  6139.      PbGetEntry          Gets all the information on an entry using either
  6140.                          the name or the record ID for a given entry.
  6141.  
  6142.      PbLookUpSendInfo    Gets an entry's phone number and hardware type
  6143.                          using either the name or record ID for a given
  6144.                          entry.
  6145.  
  6146.  
  6147. Entry Modification
  6148.      These functions add, change, or remove entries.
  6149.  
  6150.      PbAddEntry          Adds a group or person into the specified
  6151.                          phonebook and updates any other affected entries.
  6152.  
  6153.      PbAddToGroup        Adds a person entry to a group and updates any
  6154.                          other affected entries.
  6155.  
  6156.      PbModifyEntry       Changes one or more fields in a phonebook entry
  6157.                          and updates any other affected entries.
  6158.  
  6159.      PbRemoveEntry       Deletes an existing entry and updates any other
  6160.                          affected entries.
  6161.  
  6162.      PbRemoveFromGroup   Deletes a person entry from a group and updates
  6163.                          any other affected entries.
  6164.  
  6165.  
  6166.  
  6167. Phonebook Buffering
  6168.      In the Toolkit, the phonebook structure uses a memory buffer that is
  6169.      variable in length for the file offsets of entries.  For details about
  6170.      how to set the size of this buffer and how it works see the reference
  6171.      page for the function PbBufferOffsets.
  6172.  
  6173.  
  6174.  
  6175.      NOTE:
  6176.           All phonebook query functions perform better if the phonebook's
  6177.           memory buffer is used (PbBufferOffset).
  6178.  
  6179.  
  6180.  
  6181.  
  6182.  
  6183.  
  6184.  
  6185.  
  6186.  
  6187.  
  6188.  
  6189.  
  6190.  
  6191.  
  6192.  
  6193.  
  6194.  
  6195.  
  6196.  
  6197.  
  6198.  
  6199.  
  6200.  
  6201.  
  6202. PBLIB:  Library For Phonebook Management                      6-3
  6203.  
  6204.  
  6205.  
  6206.  
  6207.  
  6208. PbAddEntry
  6209.  
  6210.  
  6211. Description
  6212.      Adds a group or person entry into the specified phonebook updating any
  6213.      other affected entries.
  6214.  
  6215.  
  6216. Summary
  6217.      #include <phonebk.h>
  6218.      #include <pbglobal.h>
  6219.  
  6220.      int PbAddEntry (pb, entry);
  6221.  
  6222.  
  6223. Input Parameters
  6224.      PB *pb;        Pointer to a phonebook structure.
  6225.  
  6226.      PBE *entry;    Pointer to a phonebook entry structure.  Complete
  6227.                     except for the record ID and length fields, which the
  6228.                     function sets.  The entry can be a person or group.
  6229.                     For information on person and group records, refer to
  6230.                     the Phonebook Format section of the DCA/Intel
  6231.                     Communicating Applications Specification.
  6232.  
  6233.  
  6234. Output Parameter
  6235.      PBE *entry;    Pointer to the added phonebook entry structure with the
  6236.                     record ID and length fields filled in.
  6237.  
  6238.  
  6239. Errors
  6240.      For a listing of the Pberrno numbers and associated messages, refer to
  6241.      PBERROR.H.
  6242.  
  6243.  
  6244. Return Value
  6245.      Returns SUCCESS or FAIL.
  6246.  
  6247.  
  6248. Remarks
  6249.      The caller must create a phonebook entry structure and must set the
  6250.      fields (except the record ID and length fields) to valid values except
  6251.      the record ID and length fields.  If the entry is a group, it must
  6252.      have at least one member in its membership list.  Also, if the entry
  6253.      is a group, the application need not set the hardware type field.
  6254.      PbAddEntry will set it.  All members in the group's membership list
  6255.      must be person entries in the phonebook.
  6256.  
  6257.      All entries must have unique names, with uppercase/lowercase
  6258.      distinction ignored.  The function returns an error if an entry
  6259.      already exists with the same name or if the name differs only in case.
  6260.  
  6261.  
  6262.  
  6263.      NOTE:
  6264.           You must open the phonebook with PbOpenPhonebook before you can
  6265.           use this function.
  6266.  
  6267.  
  6268. 6-4                      PBLIB:  Library For Phonebook Management
  6269.  
  6270.  
  6271.  
  6272.  
  6273.  
  6274.                                                        PbAddEntry
  6275. See Also
  6276.      PbOpenPhonebook, PbModifyEntry, PbRemoveEntry
  6277.  
  6278.  
  6279. Example Program
  6280.      The following program prompts for a name and phone number, adds the
  6281.      entry to the default phonebook, and displays whether the entry was
  6282.      successfully added.
  6283.  
  6284.      #include <stdio.h>
  6285.      #include <phonebk.h>
  6286.      #include <pberror.h>
  6287.      #include <pbglobal.h>
  6288.  
  6289.      char  *pbname = "c:\\connect\\default.pb";
  6290.  
  6291.      main()
  6292.      {
  6293.        PB  phonebook, *result;
  6294.        PBE entry;
  6295.        int  i;
  6296.        if (result = PbOpenPhonebook(&phonebook,
  6297.                                     pbname))  {
  6298.          entry.id = 0;
  6299.          entry.members = 0;
  6300.          entry.length = 0;
  6301.          entry.type = PERSONENTRY;
  6302.          entry.HardwareType = FAXONLY;
  6303.          printf("Enter name of entry - ");
  6304.          gets(entry.name);
  6305.          printf("\nEnter phone number - ");
  6306.          gets(entry.PhoneNumber);
  6307.          if (phonebook.header.fields > 0)
  6308.            entry.fields = (char **)malloc(phonebook.
  6309.                      header.fields * sizeof(char *));
  6310.          for (i=0; i<phonebook.header.fields; i++)
  6311.            entry.fields[i] = (char *)malloc(60 *
  6312.                                       sizeof(char));
  6313.          printf("Comments:  - ");
  6314.          gets(entry.fields[0]);
  6315.          printf("Voice phone: - ");
  6316.          gets(entry.fields[1]);
  6317.          if (PbAddEntry(&phonebook,&entry))   {
  6318.            printf("\n%s added to %s \n",
  6319.                   entry.name, pbname);
  6320.            printf("RecordID=%d Record Length=%d\n",
  6321.                   entry.id, entry.length);
  6322.          }
  6323.          else   {
  6324.            printf("\nError adding entry \n");
  6325.            printf("Message is %s \n",
  6326.                   PBerrlist[Pberrno]);
  6327.          }
  6328.        for (i=0; i<phonebook.header.fields; i++)
  6329.          if(entry.fields[i])
  6330.            free(entry.fields[i]);
  6331.        if(entry.fields)
  6332.          free(entry.fields);
  6333.        fclose(phonebook.fp);
  6334. PBLIB:  Library For Phonebook Management                      6-5
  6335.  
  6336.  
  6337.  
  6338.  
  6339.  
  6340. PbAddEntry
  6341.        }
  6342.        else       {
  6343.        printf("\nError opening phonebook \n");
  6344.        printf("Message is %s \n",
  6345.                   PBerrlist[Pberrno]);
  6346.        }
  6347.      }
  6348.  
  6349.  
  6350.  
  6351.  
  6352.  
  6353.  
  6354.  
  6355.  
  6356.  
  6357.  
  6358.  
  6359.  
  6360.  
  6361.  
  6362.  
  6363.  
  6364.  
  6365.  
  6366.  
  6367.  
  6368.  
  6369.  
  6370.  
  6371.  
  6372.  
  6373.  
  6374.  
  6375.  
  6376.  
  6377.  
  6378.  
  6379.  
  6380.  
  6381.  
  6382.  
  6383.  
  6384.  
  6385.  
  6386.  
  6387.  
  6388.  
  6389.  
  6390.  
  6391.  
  6392.  
  6393.  
  6394.  
  6395.  
  6396.  
  6397.  
  6398.  
  6399.  
  6400. 6-6                      PBLIB:  Library For Phonebook Management
  6401.  
  6402.  
  6403.  
  6404.  
  6405.  
  6406.                                                     PbAddToGroup
  6407.  
  6408.  
  6409. Description
  6410.      Adds a person entry to a group updating any other affected entries.
  6411.  
  6412.  
  6413. Summary
  6414.      #include <phonebk.h>
  6415.      #include <pbglobal.h>
  6416.  
  6417.      int PbAddToGroup (pb, groupID, memberID);
  6418.  
  6419.  
  6420. Input Parameter
  6421.      PB *pb:        Pointer to a phonebook structure.
  6422.  
  6423.      int groupID;   Record ID of a group phonebook entry.
  6424.  
  6425.      int memberID;  Record ID of a person entry to add to the specified
  6426.                     group.
  6427.  
  6428.  
  6429. Output Parameter
  6430.      PB *pb;        Modified phonebook structure.
  6431.  
  6432.  
  6433. Errors
  6434.      For a listing of the Pberrno numbers and associated messages, refer to
  6435.      PBERROR.H.
  6436.  
  6437.  
  6438. Return Value
  6439.      Returns SUCCESS or FAIL.  The function fails if either the person
  6440.      entry or the group entry doesn't exist, if they are not the right
  6441.      entry type (person or group), or if the person is already a member of
  6442.      that group.
  6443.  
  6444.  
  6445. Remarks
  6446.      This function adds a specified member to the group's membership list
  6447.      and adds the group to the membership list of the member.
  6448.  
  6449.      This function uses the entry's and group's record ID numbers to access
  6450.      them.  If only the name of the entry or the group is known, the
  6451.      application can find the record ID by using either the PbGetEntry or
  6452.      the PbFindFirstOrNext functions.
  6453.  
  6454.  
  6455.  
  6456.      NOTE:
  6457.           You must open the phonebook with PbOpenPhonebook before you can
  6458.           use this function.
  6459.  
  6460.           If the hardware type of the person added is FAXONLY and that of
  6461.           the group is HASCCC, the function changes the group's type to
  6462.           FAXONLY.
  6463.  
  6464.  
  6465.  
  6466. PBLIB:  Library For Phonebook Management                      6-7
  6467.  
  6468.  
  6469.  
  6470.  
  6471.  
  6472. PbAddToGroup
  6473. See Also
  6474.      PbOpenPhonebook, PbAddEntry, PbRemoveFromGroup, PbGetEntry,
  6475.      PbFindFirstOrNext
  6476.  
  6477.  
  6478. Example Program
  6479.      The following program prompts for a person entry and a group entry.
  6480.      It then adds the person entry to that group and displays whether the
  6481.      addition was a success.
  6482.  
  6483.      #include <stdio.h>
  6484.      #include <phonebk.h>
  6485.      #include <pberror.h>
  6486.      #include <pbglobal.h>
  6487.  
  6488.      char  *pbname = "c:\\connect\\default.pb";
  6489.  
  6490.      main()
  6491.      {
  6492.        PB  phonebook, *result;
  6493.        PBE *person, *group;
  6494.        int  rid = -1;
  6495.        char  aperson[32];
  6496.        char  agroup[32];
  6497.  
  6498.        if (result = PbOpenPhonebook(&phonebook,
  6499.                                     pbname))  {
  6500.          printf("Enter person adding to group - ");
  6501.          gets(aperson);
  6502.          printf("\nEnter group adding person to - ");
  6503.          gets(agroup);
  6504.          if (person = PbGetEntry(&phonebook, NULL,
  6505.                             aperson, rid))  {
  6506.            if (group = PbGetEntry(&phonebook, NULL,
  6507.                             agroup, rid)) {
  6508.              if(PbAddToGroup(&phonebook,group->id,
  6509.                              person->id))  {
  6510.                printf("Successfully added %s to %s\n",
  6511.                       aperson, agroup);
  6512.                PbFreePBE(&phonebook, group);
  6513.              }
  6514.              else   {
  6515.                printf("\nError adding to  group \n");
  6516.                printf("Message is %s \n",
  6517.                     PBerrlist[Pberrno]);
  6518.              }
  6519.            }
  6520.            else  {
  6521.              printf("\nError getting group \n");
  6522.              printf("Message is %s \n",
  6523.                     PBerrlist[Pberrno]);
  6524.            }
  6525.            PbFreePBE(&phonebook, person);
  6526.          }
  6527.          else {
  6528.            printf("\nError getting person \n");
  6529.            printf("Message is %s \n",
  6530.                   PBerrlist[Pberrno]);
  6531.          }
  6532. 6-8                      PBLIB:  Library For Phonebook Management
  6533.  
  6534.  
  6535.  
  6536.  
  6537.  
  6538.                                                     PbAddToGroup
  6539.          fclose(phonebook.fp);
  6540.        }
  6541.        else       {
  6542.            printf("\nError opening phonebook \n");
  6543.            printf("Message is %s \n",
  6544.                   PBerrlist[Pberrno]);
  6545.        }
  6546.      }
  6547.  
  6548.  
  6549.  
  6550.  
  6551.  
  6552.  
  6553.  
  6554.  
  6555.  
  6556.  
  6557.  
  6558.  
  6559.  
  6560.  
  6561.  
  6562.  
  6563.  
  6564.  
  6565.  
  6566.  
  6567.  
  6568.  
  6569.  
  6570.  
  6571.  
  6572.  
  6573.  
  6574.  
  6575.  
  6576.  
  6577.  
  6578.  
  6579.  
  6580.  
  6581.  
  6582.  
  6583.  
  6584.  
  6585.  
  6586.  
  6587.  
  6588.  
  6589.  
  6590.  
  6591.  
  6592.  
  6593.  
  6594.  
  6595.  
  6596.  
  6597.  
  6598. PBLIB:  Library For Phonebook Management                      6-9
  6599.  
  6600.  
  6601.  
  6602.  
  6603.  
  6604. PbBufferOffsets
  6605.  
  6606.  
  6607. Description
  6608.      Sets up the phonebook structure's offset buffer for all phonebook
  6609.      entry queries and modifications.  The offset buffer stores phonebook
  6610.      information in memory to improve performance.
  6611.  
  6612.  
  6613. Summary
  6614.      #include <phonebk.h>
  6615.      #include <pbglobal.h>
  6616.  
  6617.      PB *PbBufferOffsets (pb, buffer, OBufferSize);
  6618.  
  6619.  
  6620. Input Parameters
  6621.      PB *pb;             Pointer to a phonebook structure of an open
  6622.                          phonebook.
  6623.  
  6624.      LONGWORD *buffer;   NULL or pointer to buffer of OBufferSize bytes.
  6625.                          Directs the function to allocate memory from
  6626.                          conventional memory by setting buffer to NULL.
  6627.  
  6628.      WORD OBufferSize;   Size to make buffer, in bytes, from 4 to a maximum
  6629.                          of 4000.  If not a multiple of 4, function rounds
  6630.                          the size down to the nearest multiple of 4.
  6631.  
  6632.  
  6633. Output Parameter
  6634.      PB *pb;             The phonebook structure with OBuffer and
  6635.                          OBufferSize initialized.
  6636.  
  6637.  
  6638. Errors
  6639.      For a listing of the Pberrno numbers and associated messages, refer to
  6640.      PBERROR.H.
  6641.  
  6642.  
  6643. Return Value
  6644.      If successful, returns the pointer to the phonebook structure.
  6645.      Otherwise, returns NULL.
  6646.  
  6647.  
  6648. Remarks
  6649.      PBLIB functions that query or modify a phonebook entry find the entry
  6650.      by its offset in the phonebook file.  The entry's record ID is an
  6651.      index into the array of offsets in the phonebook file header.  If the
  6652.      offset buffer has been set up by calling PbBufferOffsets and the
  6653.      offset sought is currently in the buffer, the functions retrieve the
  6654.      offset sought from there.  If the offset is not there, the functions
  6655.      read the portion of the offset array that contains the offset into the
  6656.      offset buffer and then retrieve it.
  6657.  
  6658.      PBLIB functions perform significantly better if the offset buffer is
  6659.      used.  For best results, set OBufferSize large enough to hold as many
  6660.      offsets as the phonebook is expected to have.  For example, to hold
  6661.      offsets for 100 entries, set OBufferSize to 400.  If the offset buffer
  6662.      is not used, PBLIB functions need to make more accesses directly to
  6663.      the phonebook file.
  6664. 6-10                     PBLIB:  Library For Phonebook Management
  6665.  
  6666.  
  6667.  
  6668.  
  6669.  
  6670.                                                  PbBufferOffsets
  6671.      This function reads OBufferSize bytes of the phonebook file's offset
  6672.      array into a memory buffer and assigns that buffer to the OBuffer
  6673.      field of the phonebook structure.  The caller either provides the
  6674.      memory for this buffer or directs the function to allocate the memory
  6675.      by setting buffer to NULL.
  6676.  
  6677.  
  6678. See Also
  6679.      PbOpenPhonebook
  6680.  
  6681.  
  6682. Example Program
  6683.      The following program opens the default phonebook, initializes an
  6684.      offset buffer to 500 bytes, and displays the buffer's contents.
  6685.  
  6686.      #include <stdio.h>
  6687.      #include <phonebk.h>
  6688.      #include <pberror.h>
  6689.      #include <pbglobal.h>
  6690.  
  6691.      char *pbname = "c:\\connect\\default.pb";
  6692.  
  6693.      main()
  6694.      {
  6695.        PB phonebook, *result;
  6696.        int i, buffsize = 500;
  6697.  
  6698.        result = PbOpenPhonebook(&phonebook, pbname);
  6699.        if (result) {
  6700.          result = PbBufferOffsets(&phonebook,
  6701.                                   NULL,
  6702.                                   buffsize);
  6703.  
  6704.  
  6705.  
  6706.  
  6707.  
  6708.  
  6709.  
  6710.  
  6711.  
  6712.  
  6713.  
  6714.  
  6715.  
  6716.  
  6717.  
  6718.  
  6719.  
  6720.  
  6721.  
  6722.  
  6723.  
  6724.  
  6725.  
  6726.  
  6727.  
  6728.  
  6729.  
  6730. PBLIB:  Library For Phonebook Management                     6-11
  6731.  
  6732.  
  6733.  
  6734.  
  6735.  
  6736. PbBufferOffsets
  6737.          if (result) {
  6738.            printf("Contents of offset buffer are:\n");
  6739.            for (i=0;
  6740.                 i<(buffsize/sizeof(LONGWORD));
  6741.                 i++) {
  6742.              if (!(i%10)) printf("\n");
  6743.              printf(" %5.4d ", phonebook.OBuffer[i]);
  6744.            }
  6745.          }
  6746.          fclose(phonebook.fp);
  6747.        }
  6748.      }
  6749.  
  6750.  
  6751.  
  6752.  
  6753.  
  6754.  
  6755.  
  6756.  
  6757.  
  6758.  
  6759.  
  6760.  
  6761.  
  6762.  
  6763.  
  6764.  
  6765.  
  6766.  
  6767.  
  6768.  
  6769.  
  6770.  
  6771.  
  6772.  
  6773.  
  6774.  
  6775.  
  6776.  
  6777.  
  6778.  
  6779.  
  6780.  
  6781.  
  6782.  
  6783.  
  6784.  
  6785.  
  6786.  
  6787.  
  6788.  
  6789.  
  6790.  
  6791.  
  6792.  
  6793.  
  6794.  
  6795.  
  6796. 6-12                     PBLIB:  Library For Phonebook Management
  6797.  
  6798.  
  6799.  
  6800.  
  6801.  
  6802.                                                PbCreatePhonebook
  6803.  
  6804.  
  6805. Description
  6806.      Creates a phonebook file consisting only of a header and 0 entries.
  6807.  
  6808.  
  6809. Summary
  6810.      #include <phonebk.h>
  6811.      #include <pbglobal.h>
  6812.  
  6813.      PB *PbCreatePhonebook (pb, name);
  6814.  
  6815.  
  6816. Input Parameters
  6817.      PB *pb;        NULL or pointer to a phonebook structure.
  6818.  
  6819.      char *name;    Pointer to a full path and name to give a new
  6820.                     phonebook.
  6821.  
  6822.  
  6823. Output Parameter
  6824.      PB *pb;        If this pointed to a phonebook structure on entry, on
  6825.                     return it is filled with the information about the new
  6826.                     phonebook.  If the pointer pb is NULL, the function
  6827.                     allocates a phonebook structure and returns that
  6828.                     structure's pointer.
  6829.  
  6830.  
  6831. Errors
  6832.      For a listing of the Pberrno numbers and associated messages, refer to
  6833.      PBERROR.H.
  6834.  
  6835.  
  6836. Return Value
  6837.      If a phonebook structure was provided by pb, it returns pb.  If pb was
  6838.      NULL, it returns a pointer to the structure allocated.
  6839.  
  6840.  
  6841. Remarks
  6842.      The phonebook file is left open for reading and writing.  The buffer
  6843.      for offsets is initially NULL.  OBufferSize is set to 0.
  6844.  
  6845.      Intel's CAS application for the Connection CoProcessor is CONNECT.EXE.
  6846.      When creating new phonebooks, applications must observe a few
  6847.      restrictions if they intend to share phonebooks with CONNECT.  They
  6848.      are as follows:
  6849.  
  6850.      ╖ Name phonebook files with the extension .PB (for example,
  6851.        sample.pb.)
  6852.  
  6853.      ╖ Keep phonebook files in the default directory for CAS software.
  6854.        This directory is found in the CAS External Data Block.
  6855.  
  6856.      ╖ Use only two of the ten "ASCIIZ variable fields."  CONNECT names
  6857.        these "Voice Phone" and "Comment."  PbCreatePhonebook uses a global
  6858.        structure for the phonebook header with these names pre-initialized.
  6859.  
  6860.  
  6861.  
  6862. PBLIB:  Library For Phonebook Management                     6-13
  6863.  
  6864.  
  6865.  
  6866.  
  6867.  
  6868. PbCreatePhonebook
  6869. See Also
  6870.      PbOpenPhonebook
  6871.  
  6872.  
  6873. Example Program
  6874.      The following program creates a new phonebook file in the c:\connect
  6875.      directory under the name "sample.pb".
  6876.  
  6877.      #include <stdio.h>
  6878.      #include <phonebk.h>
  6879.      #include <pberror.h>
  6880.      #include <pbglobal.h>
  6881.  
  6882.      char *pbname = "c:\\connect\\sample.pb";
  6883.  
  6884.      main()
  6885.      {
  6886.        PB phonebook, *result;
  6887.  
  6888.        result = PbCreatePhonebook(&phonebook,
  6889.                                   pbname);
  6890.        if (result) {
  6891.          printf("New phonebook %s created\n", pbname);
  6892.          fclose(phonebook.fp);
  6893.          }
  6894.        else
  6895.          printf("CreatePhonebook error, msg is:\n%s",
  6896.                 PBerrlist[Pberrno]);
  6897.        }
  6898.  
  6899.  
  6900.  
  6901.  
  6902.  
  6903.  
  6904.  
  6905.  
  6906.  
  6907.  
  6908.  
  6909.  
  6910.  
  6911.  
  6912.  
  6913.  
  6914.  
  6915.  
  6916.  
  6917.  
  6918.  
  6919.  
  6920.  
  6921.  
  6922.  
  6923.  
  6924.  
  6925.  
  6926.  
  6927.  
  6928. 6-14                     PBLIB:  Library For Phonebook Management
  6929.  
  6930.  
  6931.  
  6932.  
  6933.  
  6934.                                                 PbFindFirstOrNext
  6935.  
  6936.  
  6937. Description
  6938.      Gets the first or the next entry whose name matches a given string
  6939.      specification, including wildcards.
  6940.  
  6941.  
  6942. Summary
  6943.      #include <phonebk.h>
  6944.      #include <pbglobal.h>
  6945.  
  6946.      PBE *PbFindFirstOrNext (pb, pbe, name, recordID);
  6947.  
  6948.  
  6949. Input Parameters
  6950.      PB *pb;             Pointer to a phonebook structure.
  6951.  
  6952.      PBE *pbe;           NULL or pointer to a phonebook entry structure.
  6953.                          If pbe is NULL on input, the function allocates
  6954.                          the memory it needs, reads the data into that
  6955.                          memory, and returns its pointer.  If a pointer to
  6956.                          a phonebook entry structure is provided, the
  6957.                          requested data is returned in that structure.
  6958.  
  6959.      char *name;         Pointer to a string specification of name whose
  6960.                          entry is sought.  This string specification may
  6961.                          contain the wildcards ? and *.
  6962.  
  6963.      int *recordID;      Pointer to a record ID from 0 to 999 or -1.  If
  6964.                          recordID is
  6965.                          -1, the function performs a "FindFirst" event by
  6966.                          finding the first entry that matches the name
  6967.                          string.  If none are found, it sets Pberrno to
  6968.                          NOENTRYFOUND and returns NULL.
  6969.  
  6970.  
  6971. Output Parameters
  6972.      PBE *pbe;           If NULL, the function allocates memory, reads the
  6973.                          data into that memory, and returns its pointer.
  6974.                          If not NULL on input, holds the data for the entry
  6975.                          requested.
  6976.  
  6977.      int *recordID;      A record ID from 0 to 999 or -1.
  6978.  
  6979.  
  6980. Errors
  6981.      For a listing of the Pberrno numbers and associated messages, refer to
  6982.      PBERROR.H.
  6983.  
  6984.  
  6985. Return Value
  6986.      If the search is successful, the function returns a pointer to the PBE
  6987.      structure holding the data for the requested entry.  Otherwise it
  6988.      returns NULL.
  6989.  
  6990.  
  6991.  
  6992.  
  6993.  
  6994. PBLIB:  Library For Phonebook Management                     6-15
  6995.  
  6996.  
  6997.  
  6998.  
  6999.  
  7000. PbFindFirstOrNext
  7001.  
  7002.      NOTE:
  7003.           You must open the phonebook with PbOpenPhonebook before you can
  7004.           use this function.
  7005.  
  7006.           All phonebook query functions perform better if the phonebook's
  7007.           offset buffer is being used (PbBufferOffsets).  For information
  7008.           on the buffer, refer to the PbBufferOffsets reference page.
  7009.  
  7010.  
  7011. Remarks
  7012.      If the exact name is specified, the function finds and returns the
  7013.      information on the entry by that name.
  7014.  
  7015.      This function performs two different events, depending on the setting
  7016.      on input of the parameter recordID.  If recordID is a valid record ID
  7017.      (0 - 999), then it is assumed to have been set by a previous call to
  7018.      this function.  The function performs a "FindNext" event.  It first
  7019.      reads the entry indicated by recordID into the phonebook entry
  7020.      structure, if there is an entry for that record ID.  If not, the
  7021.      function sets Pberrno to NOENTRYFOUND and returns NULL.  It then
  7022.      searches for another entry that matches the name string.  If it finds
  7023.      one, it sets recordID to the record ID of the entry found.  If it
  7024.      doesn't find any, it sets Pberrno to NOMOREMATCH.  If recordID is -1,
  7025.      it performs a "Find First" event.
  7026.  
  7027.  
  7028. See Also
  7029.      PbOpenPhonebook, PbLookUpSendInfo, PbGetEntry, and PbFreePBE
  7030.  
  7031.  
  7032. Example Program
  7033.      The following program uses the wildcard "*" to search the phonebook
  7034.      for all matching entries and prints the ID number, name, and phone
  7035.      number of each matching entry.
  7036.  
  7037.      #include <stdio.h>
  7038.      #include <phonebk.h>
  7039.      #include <pberror.h>
  7040.      #include <pbglobal.h>
  7041.  
  7042.      char  *pbname = "c:\\connect\\default.pb";
  7043.  
  7044.      main()
  7045.      {
  7046.        PB  phonebook, *result;
  7047.        PBE *entry;
  7048.        int rid = -1;
  7049.        char name[32];
  7050.  
  7051.        if (result = PbOpenPhonebook(&phonebook,
  7052.                                     pbname)) {
  7053.          printf("\nEnter search name using wildcards * or ? - ");
  7054.          gets(name);
  7055.          printf("\nMatching entries are: \n");
  7056.          printf("Record    Name              ");
  7057.          printf("               Phone Number\n");
  7058.          do {
  7059.            if (entry = PbFindFirstOrNext(&phonebook,
  7060. 6-16                     PBLIB:  Library For Phonebook Management
  7061.  
  7062.  
  7063.  
  7064.  
  7065.  
  7066.                                                 PbFindFirstOrNext
  7067.                                          NULL,
  7068.                                          name, &rid)) {
  7069.              printf("%6d    %-32s %-32s \n",entry->id,
  7070.                     entry->name, entry->PhoneNumber);
  7071.            }
  7072.            if (Pberrno == NOMOREMATCH)
  7073.              break;
  7074.          } while (entry);
  7075.          printf("No more matching entries\n");
  7076.          PbFreePBE(&phonebook, entry);
  7077.          fclose(phonebook.fp);
  7078.        }
  7079.        else       {
  7080.          printf("\nError opening phonebook \n");
  7081.          printf("Message is %s \n",
  7082.                 PBerrlist[Pberrno]);
  7083.        }
  7084.      }
  7085.  
  7086.  
  7087.  
  7088.  
  7089.  
  7090.  
  7091.  
  7092.  
  7093.  
  7094.  
  7095.  
  7096.  
  7097.  
  7098.  
  7099.  
  7100.  
  7101.  
  7102.  
  7103.  
  7104.  
  7105.  
  7106.  
  7107.  
  7108.  
  7109.  
  7110.  
  7111.  
  7112.  
  7113.  
  7114.  
  7115.  
  7116.  
  7117.  
  7118.  
  7119.  
  7120.  
  7121.  
  7122.  
  7123.  
  7124.  
  7125.  
  7126. PBLIB:  Library For Phonebook Management                     6-17
  7127.  
  7128.  
  7129.  
  7130.  
  7131.  
  7132. PbFreePBE
  7133.  
  7134.  
  7135. Description
  7136.      Frees the memory used by a phonebook entry structure.
  7137.  
  7138.  
  7139. Summary
  7140.      #include <phonebk.h>
  7141.      #include <pbglobal.h>
  7142.  
  7143.      void PbFreePBE (pb, entry);
  7144.  
  7145.  
  7146. Input Parameters
  7147.      PB *pb;        Pointer to a phonebook structure.
  7148.  
  7149.      PBE *entry;    Pointer to a phonebook entry structure.
  7150.  
  7151.  
  7152. Output Parameters
  7153.      None.
  7154.  
  7155.  
  7156. Errors
  7157.      For a listing of the Pberrno numbers and associated messages, refer to
  7158.      PBERROR.H.
  7159.  
  7160.  
  7161. Return Value
  7162.      None.
  7163.  
  7164.  
  7165. Remarks
  7166.      The memory used by the entry must be conventional memory, allocated by
  7167.      the standard C functions malloc, calloc, or realloc.  The memory can
  7168.      also be allocated by any PBLIB function that uses those standard C
  7169.      functions, such as PbGetEntry or PbFindFirstOrNext.
  7170.  
  7171.      This function has no effect on the entry information in the phonebook
  7172.      file or the phonebook structure.
  7173.  
  7174.      This function frees the memory used by the entry and all its variable-
  7175.      length fields.
  7176.  
  7177.  
  7178.  
  7179.      NOTE:
  7180.           You must open the phonebook with PbOpenPhonebook before you can
  7181.           use this function.
  7182.  
  7183.           If either the phonebook or entry parameters are NULL, the
  7184.           function sets Pberrno to INVALIDPARAMETERS and doesn't free any
  7185.           memory.  If any of the pointer fields of the entry to be
  7186.           initialized are NULL, the function sets Pberrno to NULLPOINTER
  7187.           but frees the initialized pointers.
  7188.  
  7189.  
  7190. See Also
  7191.      PbGetEntry, PbFindFirstOrNext
  7192. 6-18                     PBLIB:  Library For Phonebook Management
  7193.  
  7194.  
  7195.  
  7196.  
  7197.  
  7198.                                                         PbFreePBE
  7199. Example Program
  7200.      The following program gets the first entry (record ID of 0) in the
  7201.      phonebook, then frees the memory used by that entry.
  7202.  
  7203.      #include <stdio.h>
  7204.      #include <phonebk.h>
  7205.      #include <pberror.h>
  7206.      #include <pbglobal.h>
  7207.      char *pbname = "c:\\connect\\default.pb";
  7208.  
  7209.      main()
  7210.      {
  7211.        PB phonebook, *result;
  7212.        PBE *entry;
  7213.        int rid = 0;
  7214.  
  7215.        result = PbOpenPhonebook(&phonebook, pbname);
  7216.        if (result) {
  7217.          entry = PbGetEntry(&phonebook, NULL, NULL, rid);
  7218.          if (entry) {
  7219.            printf("The first entry in %s is %s\n",
  7220.                   pbname, entry->name);
  7221.            PbFreePBE(&phonebook, entry);
  7222.          }
  7223.          else {
  7224.            printf("First entry in %s not found\n");
  7225.          }
  7226.          fclose(phonebook.fp);
  7227.        }
  7228.      }
  7229.      
  7230.  
  7231.  
  7232.  
  7233.  
  7234.  
  7235.  
  7236.  
  7237.  
  7238.  
  7239.  
  7240.  
  7241.  
  7242.  
  7243.  
  7244.  
  7245.  
  7246.  
  7247.  
  7248.  
  7249.  
  7250.  
  7251.  
  7252.  
  7253.  
  7254.  
  7255.  
  7256.  
  7257.  
  7258. PBLIB:  Library For Phonebook Management                     6-19
  7259.  
  7260.  
  7261.  
  7262.  
  7263.  
  7264. PbGarbageCollect
  7265.  
  7266.  
  7267. Description
  7268.      Eliminates unused space in a phonebook file that can accumulate
  7269.      through entry deletions and modifications.
  7270.  
  7271.  
  7272. Summary
  7273.      #include <phonebk.h>
  7274.      #include <pbglobal.h>
  7275.  
  7276.      int PbGarbageCollect (pbFilename);
  7277.  
  7278.  
  7279. Input Parameters
  7280.      char *pbFilename;   Pointer to a name of a closed phonebook file.
  7281.  
  7282.  
  7283. Output Parameter
  7284.      None.
  7285.  
  7286.  
  7287. Errors
  7288.      For a listing of the Pberrno numbers and associated messages, refer to
  7289.      PBERROR.H.
  7290.  
  7291.  
  7292. Return Value
  7293.      Returns SUCCESS or FAIL.  To perform the garbage collection,
  7294.      PbGarbageCollect must create a new copy of the phonebook on the disk.
  7295.      The function checks for disk space before creating the new phonebook.
  7296.      If there is not enough disk space to perform the operation, the
  7297.      function doesn't create the copy and returns FAIL.
  7298.  
  7299.  
  7300.  
  7301.      NOTE:
  7302.           The phonebook file must be closed to use this function, and, upon
  7303.           return, the phonebook file is left closed.
  7304.  
  7305.  
  7306. See Also
  7307.      None.
  7308.  
  7309.  
  7310.  
  7311.  
  7312.  
  7313.  
  7314.  
  7315.  
  7316.  
  7317.  
  7318.  
  7319.  
  7320.  
  7321.  
  7322.  
  7323.  
  7324. 6-20                     PBLIB:  Library For Phonebook Management
  7325.  
  7326.  
  7327.  
  7328.  
  7329.  
  7330.                                                  PbGarbageCollect
  7331. Example Program
  7332.      The following program removes all unused bytes from the default
  7333.      phonebook.
  7334.  
  7335.      #include <stdio.h>
  7336.      #include <phonebk.h>
  7337.      #include <pberror.h>
  7338.      #include <pbglobal.h>
  7339.  
  7340.      char *pbname = "c:\\connect\\default.pb";
  7341.  
  7342.      main()
  7343.      {
  7344.        PB phonebook, *result;
  7345.  
  7346.        result = PbOpenPhonebook(&phonebook, pbname);
  7347.        if (result) {
  7348.          printf("Phonebook %s has %d unused bytes\n",
  7349.                 pbname,
  7350.                 phonebook.header.FreeBytes);
  7351.          fclose(phonebook.fp);
  7352.          if (PbGarbageCollect(pbname)) {
  7353.            result = PbOpenPhonebook(&phonebook,
  7354.                                     pbname);
  7355.            if (result) {
  7356.              printf("\n%s now has %d unused bytes\n",
  7357.                  pbname,
  7358.                  phonebook.header.FreeBytes);
  7359.            }
  7360.            else {
  7361.              printf("GarbageCollect error,msg is:\n%s",
  7362.                     PBerrlist[Pberrno]);
  7363.            }
  7364.          }
  7365.        }
  7366.        else {
  7367.          printf("OpenPhonebook error, msg is:\n%s",
  7368.                 PBerrlist[Pberrno]);
  7369.        }
  7370.      }
  7371.      
  7372.  
  7373.  
  7374.  
  7375.  
  7376.  
  7377.  
  7378.  
  7379.  
  7380.  
  7381.  
  7382.  
  7383.  
  7384.  
  7385.  
  7386.  
  7387.  
  7388.  
  7389.  
  7390. PBLIB:  Library For Phonebook Management                     6-21
  7391.  
  7392.  
  7393.  
  7394.  
  7395.  
  7396. PbGetEntry
  7397.  
  7398.  
  7399.  
  7400. Description
  7401.      Gets all the information on an entry, using either the name or the
  7402.      record ID of a given entry.
  7403.  
  7404.  
  7405. Summary
  7406.      #include <phonebk.h>
  7407.      #include <pbglobal.h>
  7408.  
  7409.      PBE *PbGetEntry (pb, pbe, name, recordID);
  7410.  
  7411.  
  7412. Input Parameters
  7413.      PB *pb;             Pointer to a phonebook structure.
  7414.  
  7415.      PBE *pbe;           NULL or pointer to a phonebook entry structure.
  7416.  
  7417.      char *name;         NULL or pointer to a name of a person or group to
  7418.                          look up.  No wildcards are allowed in the name.
  7419.  
  7420.      int recordID;       A record ID from 0 to 999, or -1.  Use name to
  7421.                          look up the information.
  7422.  
  7423.  
  7424. Output Parameter
  7425.      PBE *pbe;           If not NULL on input, holds the data on the
  7426.                          requested entry.  If NULL, the function allocates
  7427.                          memory and returns the pointer to that memory.
  7428.  
  7429.  
  7430. Errors
  7431.      For a listing of the Pberrno numbers and associated messages, refer to
  7432.      PBERROR.H.
  7433.  
  7434.  
  7435. Return Value
  7436.      If successful, returns a pointer to the phonebook entry structure
  7437.      holding data for the requested entry.  Otherwise, returns NULL.
  7438.  
  7439.  
  7440. Remarks
  7441.      If both recordID and name are specified, the record ID takes
  7442.      precedence.  The complete entry information for a group includes the
  7443.      group's membership list, so this function is useful for obtaining the
  7444.      record IDs of all the members of a group.
  7445.  
  7446.      If the parameter pbe is not NULL on input, it is assumed to point to a
  7447.      phonebook entry structure.  The data from the requested entry is read
  7448.      into that structure, and the function returns a pointer to it.  If pbe
  7449.      is NULL on input, the function allocates the memory it needs for the
  7450.      requested entry, reads the data into that, and returns its pointer.
  7451.  
  7452.  
  7453.  
  7454.  
  7455.  
  7456. 6-22                     PBLIB:  Library For Phonebook Management
  7457.  
  7458.  
  7459.  
  7460.  
  7461.  
  7462.                                                        PbGetEntry
  7463.  
  7464.      NOTE:
  7465.           You must open the phonebook with PbOpenPhonebook before you can
  7466.           use this function.
  7467.  
  7468.  
  7469. See Also
  7470.      PbOpenPhonebook, PbFindFirstOrNext, PbLookUpSendInfo
  7471.  
  7472.  
  7473. Example Program
  7474.      The following program gets the entry requested by name in the
  7475.      phonebook and prints the phone number.
  7476.  
  7477.      #include <stdio.h>
  7478.      #include <phonebk.h>
  7479.      #include <pberror.h>
  7480.      #include <pbglobal.h>
  7481.  
  7482.      char  *pbname = "c:\\connect\\default.pb";
  7483.  
  7484.      main()
  7485.      {
  7486.        PB  phonebook, *result;
  7487.        PBE *entry;
  7488.        int rid = -1;
  7489.        char name[32];
  7490.  
  7491.        if (result = PbOpenPhonebook(&phonebook,
  7492.                                     pbname))  {
  7493.          printf("\nEnter exact name ");
  7494.          printf("(no wild cards allowed) :");
  7495.          gets(name);
  7496.          printf("\nName                     ");
  7497.          printf("               Phone Number\n");
  7498.          if (entry = PbGetEntry(&phonebook, NULL,
  7499.                                 name, rid)) {
  7500.            printf("%-32s        %-32s \n",
  7501.                   entry->name, entry->PhoneNumber);
  7502.            PbFreePBE(&phonebook, entry);
  7503.          }
  7504.          else  {
  7505.            printf("\nError getting entry %s\n", name);
  7506.            printf("Message is %s \n",
  7507.                   PBerrlist[Pberrno]);
  7508.          }
  7509.          fclose(phonebook.fp);
  7510.        }
  7511.        else       {
  7512.          printf("\nError opening phonebook \n");
  7513.          printf("Message is %s \n",
  7514.                 PBerrlist[Pberrno]);
  7515.        }
  7516.      }
  7517.  
  7518.  
  7519.  
  7520.  
  7521.  
  7522. PBLIB:  Library For Phonebook Management                     6-23
  7523.  
  7524.  
  7525.  
  7526.  
  7527.  
  7528. PbLookUpSendInfo
  7529.  
  7530.  
  7531. Description
  7532.      Gets an entry's phone number and hardware type using either the name
  7533.      or record ID for a given entry.
  7534.  
  7535.  
  7536. Summary
  7537.      #include <phonebk.h>
  7538.      #include <pbglobal.h>
  7539.  
  7540.      int PbLookUpSendInfo (pb, name, recordID, PhoneNumber, CommHardware);
  7541.  
  7542.  
  7543. Input Parameters
  7544.      PB *pb;             Pointer to a phonebook structure.
  7545.  
  7546.      char *name;         Pointer to a name of the entry (person or group)
  7547.                          to look up.
  7548.  
  7549.      int *recordID;      Pointer to a -1 or record ID of entry record to
  7550.                          look up.
  7551.  
  7552.  
  7553. Output Parameters
  7554.      char *name;         If the record ID was used, the name of the entry
  7555.                          found.
  7556.  
  7557.      int *recordID;      If the name was used, the record ID of the entry
  7558.                          found.
  7559.  
  7560.      char *PhoneNumber;  Pointer to phone number of entry found.  String
  7561.                          must be large enough to hold 47 characters.
  7562.  
  7563.      BYTE *CommHardware; Pointer to the hardware type (FAXONLY or HASCCC).
  7564.                          If HASCCC, the destination is a Connection
  7565.                          CoProcessor and can receive both faxes and file
  7566.                          transfers.
  7567.  
  7568.  
  7569. Errors
  7570.      For a listing of the Pberrno numbers and associated messages, refer to
  7571.      PBERROR.H.
  7572.  
  7573.  
  7574. Return Value
  7575.      Returns SUCCESS if the indicated entry was found in the phonebook.
  7576.      Otherwise, returns FAIL.
  7577.  
  7578.  
  7579. Remarks
  7580.      If recordID is -1, the function finds the entry for the given name and
  7581.      fills in the PhoneNumber, CommHardware and recordID parameters.  If
  7582.      recordID is set to a valid record ID (0 -999), this function finds the
  7583.      entry with that record ID, and fills the name parameter as well as
  7584.      PhoneNumber and CommHardware.  If the name was used for the lookup, it
  7585.      must be exact, except for case.  (The PbFindFirstOrNext function does
  7586.      wildcard searching.)
  7587.  
  7588. 6-24                     PBLIB:  Library For Phonebook Management
  7589.  
  7590.  
  7591.  
  7592.  
  7593.  
  7594.                                                  PbLookUpSendInfo
  7595.  
  7596.      NOTE:
  7597.           You must open the phonebook with PbOpenPhonebook before you can
  7598.           use this function.
  7599.  
  7600.  
  7601. See Also
  7602.      PbOpenPhonebook, PbFindFirstOrNext, PbGetEntry
  7603.  
  7604.  
  7605. Example Program
  7606.      The following program looks up and displays the information needed for
  7607.      sending the requested entry in the default phonebook.
  7608.  
  7609.      #include <stdio.h>
  7610.      #include <phonebk.h>
  7611.      #include <pberror.h>
  7612.      #include <pbglobal.h>
  7613.  
  7614.      char  *pbname = "c:\\connect\\default.pb";
  7615.  
  7616.      main()
  7617.      {
  7618.        PB  phonebook, *result;
  7619.        int rid = -1;
  7620.        BYTE hware;
  7621.        char name[32];
  7622.        char phone[47];
  7623.  
  7624.        if (result = PbOpenPhonebook(&phonebook,
  7625.                                     pbname))  {
  7626.          printf("\nEnter exact name for ");
  7627.          printf("minimum send info: ");
  7628.          gets(name);
  7629.          if (PbLookUpSendInfo(&phonebook, name,
  7630.                               &rid, phone, &hware)) {
  7631.  
  7632.  
  7633.  
  7634.  
  7635.  
  7636.  
  7637.  
  7638.  
  7639.  
  7640.  
  7641.  
  7642.  
  7643.  
  7644.  
  7645.  
  7646.  
  7647.  
  7648.  
  7649.  
  7650.  
  7651.  
  7652.  
  7653.  
  7654. PBLIB:  Library For Phonebook Management                     6-25
  7655.  
  7656.  
  7657.  
  7658.  
  7659.  
  7660. PbLookUpSendInfo
  7661.            printf("\nName: %s", name);
  7662.            printf("\nRecord ID: %4d", rid);
  7663.            printf("\nPhone: %s", phone);
  7664.            printf("\nHardware type: %d", hware);
  7665.          }
  7666.          else  {
  7667.            printf("\nError getting send information\n");
  7668.            printf("Message is %s \n",
  7669.                   PBerrlist[Pberrno]);
  7670.          }
  7671.          fclose(phonebook.fp);
  7672.        }
  7673.        else  {
  7674.          printf("\nError opening phonebook \n");
  7675.          printf("Message is %s \n",
  7676.                 PBerrlist[Pberrno]);
  7677.        }
  7678.      }
  7679.  
  7680.  
  7681.  
  7682.  
  7683.  
  7684.  
  7685.  
  7686.  
  7687.  
  7688.  
  7689.  
  7690.  
  7691.  
  7692.  
  7693.  
  7694.  
  7695.  
  7696.  
  7697.  
  7698.  
  7699.  
  7700.  
  7701.  
  7702.  
  7703.  
  7704.  
  7705.  
  7706.  
  7707.  
  7708.  
  7709.  
  7710.  
  7711.  
  7712.  
  7713.  
  7714.  
  7715.  
  7716.  
  7717.  
  7718.  
  7719.  
  7720. 6-26                     PBLIB:  Library For Phonebook Management
  7721.  
  7722.  
  7723.  
  7724.  
  7725.  
  7726.                                                     PbModifyEntry
  7727.  
  7728.  
  7729. Description
  7730.      Changes one or more fields in a phonebook entry updating any other
  7731.      affected entries.
  7732.  
  7733.  
  7734. Summary
  7735.      #include <phonebk.h>
  7736.      #include <pbglobal.h>
  7737.  
  7738.      int PbModifyEntry (pb, recordID, ChangedEntry);
  7739.  
  7740.  
  7741. Input Parameters
  7742.      PB *pb;             Pointer to a phonebook structure.
  7743.  
  7744.      int recordID;       Record ID of a phonebook entry already in the
  7745.                          phonebook.
  7746.  
  7747.      PBE *ChangedEntry;  Pointer to a phonebook entry structure holding
  7748.                          changed information for a phonebook entry.  All
  7749.                          fields can be changed except the record ID field.
  7750.                          If the entry's length changes, the function
  7751.                          calculates the new length and sets the length
  7752.                          field.
  7753.  
  7754.  
  7755. Output Parameter
  7756.      PB *pb;             The OBuffer field may be updated to contain the
  7757.                          changed entry's offset.
  7758.  
  7759.  
  7760. Errors
  7761.      For a listing of the Pberrno numbers and associated messages, refer to
  7762.      PBERROR.H.
  7763.  
  7764.  
  7765. Return Value
  7766.      Returns SUCCESS or FAIL.  Function fails if it does not find an entry
  7767.      with the given record ID.
  7768.  
  7769.  
  7770. Remarks
  7771.      The caller supplies a record ID and a phonebook entry structure.  The
  7772.      function writes all the fields of that structure (except the record ID
  7773.      field) into the entry indicated by the recordID parameter.
  7774.  
  7775.      An application can obtain the entry structure from a call to
  7776.      PbGetEntry or PbFindFirstOrNext, change one or more of its fields, and
  7777.      call this function with that entry structure as the ChangedEntry
  7778.      parameter.
  7779.  
  7780.  
  7781.  
  7782.      NOTE:
  7783.           You must open the phonebook with PbOpenPhonebook before you can
  7784.           use this function.
  7785.  
  7786. PBLIB:  Library For Phonebook Management                     6-27
  7787.  
  7788.  
  7789.  
  7790.  
  7791.  
  7792. PbModifyEntry
  7793.           This function does not make any changes to group entries except a
  7794.           name change.  It also does not make changes to membership
  7795.           information in any entries.  To make any changes to the
  7796.           membership of entries, use the functions PbAddToGroup and
  7797.           PbRemoveFromGroup.
  7798.  
  7799.           This function does not change the type of entry (person or
  7800.           group).
  7801.  
  7802.  
  7803. See Also
  7804.      PbOpenPhonebook, PbGetEntry, PbFindFirstOrNext
  7805.  
  7806.  
  7807. Example Program
  7808.      The following program modifies the phone number field of the requested
  7809.      entry in the default phonebook and displays a message if success.
  7810.  
  7811.      #include <stdio.h>
  7812.      #include <phonebk.h>
  7813.      #include <pberror.h>
  7814.      #include <pbglobal.h>
  7815.  
  7816.      char  *pbname = "c:\\connect\\default.pb";
  7817.  
  7818.      main()
  7819.      {
  7820.        PB  phonebook, *result;
  7821.        PBE *entry;
  7822.        int rid = -1;
  7823.        char name[32];
  7824.  
  7825.        if (result = PbOpenPhonebook(&phonebook,
  7826.                                     pbname))  {
  7827.          printf("\nEnter exact name of entry ");
  7828.          printf("you wish to change phone of: ");
  7829.          gets(name);
  7830.          if (entry = PbGetEntry(&phonebook, NULL,
  7831.                                 name, rid))  {
  7832.            printf("\nName : %s\n", entry->name);
  7833.            printf("Phone : %s\n",
  7834.                   entry->PhoneNumber);
  7835.            printf("Enter new phone: ");
  7836.            gets(entry->PhoneNumber);
  7837.            rid = entry->id;
  7838.            if (PbModifyEntry(&phonebook,
  7839.                              rid, entry))   {
  7840.              printf("Phone of %s successfully ",name);
  7841.              printf("changed to %s ",
  7842.                     entry->PhoneNumber);
  7843.            }
  7844.            else  {
  7845.              printf("Error modifying entry\n");
  7846.              printf("Message is %s \n",
  7847.                     PBerrlist[Pberrno]);
  7848.            }
  7849.          PbFreePBE(&phonebook, entry);
  7850.          }
  7851.          else  {
  7852. 6-28                     PBLIB:  Library For Phonebook Management
  7853.  
  7854.  
  7855.  
  7856.  
  7857.  
  7858.                                                     PbModifyEntry
  7859.            printf("Error getting entry\n");
  7860.            printf("Message is %s \n",
  7861.                     PBerrlist[Pberrno]);
  7862.          }
  7863.        fclose(phonebook.fp);
  7864.        }
  7865.        else  {
  7866.          printf("\nError opening phonebook \n");
  7867.          printf("Message is %s \n",
  7868.                 PBerrlist[Pberrno]);
  7869.        }
  7870.      }
  7871.  
  7872.  
  7873.  
  7874.  
  7875.  
  7876.  
  7877.  
  7878.  
  7879.  
  7880.  
  7881.  
  7882.  
  7883.  
  7884.  
  7885.  
  7886.  
  7887.  
  7888.  
  7889.  
  7890.  
  7891.  
  7892.  
  7893.  
  7894.  
  7895.  
  7896.  
  7897.  
  7898.  
  7899.  
  7900.  
  7901.  
  7902.  
  7903.  
  7904.  
  7905.  
  7906.  
  7907.  
  7908.  
  7909.  
  7910.  
  7911.  
  7912.  
  7913.  
  7914.  
  7915.  
  7916.  
  7917.  
  7918. PBLIB:  Library For Phonebook Management                     6-29
  7919.  
  7920.  
  7921.  
  7922.  
  7923.  
  7924. PbOpenPhonebook
  7925.  
  7926.  
  7927. Description
  7928.      Opens an existing phonebook file for query or modification.
  7929.  
  7930.  
  7931. Summary
  7932.      #include <phonebk.h>
  7933.      #include <pbglobal.h>
  7934.  
  7935.      PB *PbOpenPhonebook (pb, name);
  7936.  
  7937.  
  7938. Input Parameters
  7939.      PB *pb;             NULL or pointer to a phonebook structure.
  7940.  
  7941.      char *name;         Pointer to a path and filename of phonebook file.
  7942.  
  7943.  
  7944. Output Parameter
  7945.      PB *pb;             If this pointed to a phonebook structure on entry,
  7946.                          on return it contains information about the named
  7947.                          phonebook.  If the pointer pb is NULL, the
  7948.                          function allocates the phonebook structure from
  7949.                          conventional memory, reads the information into
  7950.                          that structure, and returns its pointer.
  7951.  
  7952.  
  7953. Errors
  7954.      For a listing of the Pberrno numbers and associated messages, refer to
  7955.      PBERROR.H.
  7956.  
  7957.  
  7958. Return Value
  7959.      If successful, returns a pointer to the phonebook structure.  If an
  7960.      error occurred, the function returns NULL.
  7961.  
  7962.  
  7963. Remarks
  7964.      The application must call this function before calling any of the
  7965.      other phonebook functions.  There are two exceptions:
  7966.      PbGarbageCollect, which requires a closed phonebook and
  7967.      PbCreatePhonebook.
  7968.  
  7969.      This function finds, opens, and reads information from the named
  7970.      phonebook into the fields of a phonebook structure and returns a
  7971.      pointer to that structure.  If a phonebook structure is provide by the
  7972.      pointer pb, the function fills that structure's fields with the
  7973.      information read.
  7974.  
  7975.      The phonebook file is opened for reading and writing.  The stream
  7976.      pointer to the file is one of the fields of the phonebook structure
  7977.      returned.  The buffer for offsets is initially NULL; OBufferSize and
  7978.      OBufferFirstRID are set to 0.
  7979.  
  7980.  
  7981.  
  7982.  
  7983.  
  7984. 6-30                     PBLIB:  Library For Phonebook Management
  7985.  
  7986.  
  7987.  
  7988.  
  7989.  
  7990.                                                   PbOpenPhonebook
  7991.  
  7992.      NOTE:
  7993.           To close a phonebook, close the phonebook file using fclose() on
  7994.           the FILE pointer field of the phonebook structure.  If the
  7995.           application allocated the memory for the phonebook structure with
  7996.           malloc() or directed PbOpenPhonebook to allocate memory by
  7997.           setting pb to NULL, the application must free that memory using
  7998.           the C Library function free().
  7999.  
  8000.  
  8001.      See Also
  8002.      PbCreatePhonebook
  8003.  
  8004.  
  8005. Example Program
  8006.      The following program opens and closes the default phonebook.
  8007.  
  8008.      #include <stdio.h>
  8009.      #include <phonebk.h>
  8010.      #include <pberror.h>
  8011.      #include <pbglobal.h>
  8012.  
  8013.  
  8014.      main()
  8015.      {
  8016.        PB phonebook, *result;
  8017.      char pbname[80] = "c:\\connect\\";
  8018.      char pbname[80]
  8019.      char *c_result
  8020.        printf("Enter name of phonebook: ");
  8021.        c_result = gets(pbname);
  8022.        result = PbOpenPhonebook(&phonebook, pbname);
  8023.        if (result) {
  8024.          printf("Phonebook %s has %d entries\n",
  8025.                 pbname,
  8026.                 phonebook.header.entries);
  8027.          fclose(phonebook.fp);
  8028.        }
  8029.        else {
  8030.          printf("OpenPhonebook error, msg is:\n%s",
  8031.                 PBerrlist[Pberrno]);
  8032.        }
  8033.      }
  8034.      
  8035.  
  8036.  
  8037.  
  8038.  
  8039.  
  8040.  
  8041.  
  8042.  
  8043.  
  8044.  
  8045.  
  8046.  
  8047.  
  8048.  
  8049.  
  8050. PBLIB:  Library For Phonebook Management                     6-31
  8051.  
  8052.  
  8053.  
  8054.  
  8055.  
  8056. PbRemoveEntry
  8057.  
  8058.  
  8059. Description
  8060.      Deletes an existing entry and updates any other affected entries.
  8061.  
  8062.  
  8063. Summary
  8064.      #include <phonebk.h>
  8065.      #include <pbglobal.h>
  8066.  
  8067.      int PbRemoveEntry (pb, recordID);
  8068.  
  8069.  
  8070. Input Parameters
  8071.      PB *pb;        Pointer to a phonebook structure.
  8072.  
  8073.      int recordID;  Record ID field of a phonebook entry structure.
  8074.  
  8075.  
  8076. Output Parameter
  8077.      PB *pb;        Pointer to the modified phonebook structure.
  8078.  
  8079.  
  8080. Errors
  8081.      For a listing of the Pberrno numbers and associated messages, refer to
  8082.      PBERROR.H.
  8083.  
  8084.  
  8085. Return Value
  8086.      Returns SUCCESS if the entry was successfully deleted from the
  8087.      phonebook.  Returns FAIL and leaves the phonebook as it was if the
  8088.      function cannot find an entry with the given record ID.
  8089.  
  8090.  
  8091. Remarks
  8092.      If the entry was a member of a group or groups, its record ID is
  8093.      removed from those groups' membership lists.  If the entry was a
  8094.      group, its record ID is removed from the membership lists of its
  8095.      members.  If the entry removed is the last remaining member of a
  8096.      group, PbRemoveEntry also removes that group.
  8097.  
  8098.      If a group is removed, the members will still be in the phonebook but
  8099.      won't be a part of that group.  To remove all members of a group, call
  8100.      PbRemoveEntry in a loop with each of the record IDs in the group's
  8101.      membership list.
  8102.  
  8103.      If the entry removed is a member of a group, the hardware type of the
  8104.      group may change.  If the hardware type of the removed member is
  8105.      FAXONLY and all other members of the group have hardware type HASCCC,
  8106.      the hardware type changes to HASCCC.
  8107.  
  8108.  
  8109.  
  8110.      NOTE:
  8111.           You must open the phonebook with PbOpenPhonebook before you can
  8112.           use this function.
  8113.  
  8114.  
  8115.  
  8116. 6-32                     PBLIB:  Library For Phonebook Management
  8117.  
  8118.  
  8119.  
  8120.  
  8121.  
  8122.                                                     PbRemoveEntry
  8123. See Also
  8124.      PbOpenPhonebook, PbRemoveFromGroup, PbGetEntry, PbFindFirstOrNext,
  8125.      PbFreePBE
  8126.  
  8127.  
  8128. Example Program
  8129.      The following program finds and removes the requested entry from the
  8130.      default phonebook.
  8131.  
  8132.      #include <stdio.h>
  8133.      #include <phonebk.h>
  8134.      #include <pberror.h>
  8135.      #include <pbglobal.h>
  8136.  
  8137.      char  *pbname = "c:\\connect\\default.pb";
  8138.  
  8139.      main()
  8140.      {
  8141.        PB  phonebook, *result;
  8142.        PBE *entry;
  8143.        int rid = -1;
  8144.        char name[32];
  8145.  
  8146.        if (result = PbOpenPhonebook(&phonebook,
  8147.                                     pbname))  {
  8148.          printf("\nEnter exact name of entry ");
  8149.          printf("to remove from phonebook: ");
  8150.          gets(name);
  8151.          if (entry = PbGetEntry(&phonebook, NULL,
  8152.                                 name, rid))  {
  8153.            rid = entry->id;
  8154.            if (PbRemoveEntry(&phonebook, rid))  {
  8155.              printf("%s removed from %s",
  8156.                     name,pbname);
  8157.            }
  8158.            else  {
  8159.              printf("Error removing entry\n");
  8160.              printf("Message is %s \n",
  8161.                     PBerrlist[Pberrno]);
  8162.            }
  8163.          PbFreePBE(&phonebook, entry);
  8164.          }
  8165.          else  {
  8166.            printf("Error getting entry\n");
  8167.            printf("Message is %s \n",
  8168.                     PBerrlist[Pberrno]);
  8169.          }
  8170.        fclose(phonebook.fp);
  8171.        }
  8172.        else  {
  8173.          printf("\nError opening phonebook \n");
  8174.          printf("Message is %s \n",
  8175.                 PBerrlist[Pberrno]);
  8176.        }
  8177.      }
  8178.  
  8179.  
  8180.  
  8181.  
  8182. PBLIB:  Library For Phonebook Management                     6-33
  8183.  
  8184.  
  8185.  
  8186.  
  8187.  
  8188. PbRemoveFromGroup
  8189.  
  8190.  
  8191. Description
  8192.      Deletes a person entry from a group updating any other affected
  8193.      entries.
  8194.  
  8195.  
  8196. Summary
  8197.      #include <phonebk.h>
  8198.      #include <pbglobal.h>
  8199.  
  8200.      int PbRemoveFromGroup (phonebook, GroupID, MemberID);
  8201.  
  8202.  
  8203. Input Parameters
  8204.      PB *phonebook; Pointer to a phonebook structure.
  8205.  
  8206.      int GroupID;   Record ID of a group phonebook entry.
  8207.  
  8208.      int MemberID;  Record ID of a person phonebook entry to delete from
  8209.                     the specified group.
  8210.  
  8211.  
  8212. Output Parameter
  8213.      PB *phonebook; Modified phonebook structure.
  8214.  
  8215.  
  8216. Errors
  8217.      For a listing of the Pberrno numbers and associated messages, refer to
  8218.      PBERROR.H.
  8219.  
  8220.  
  8221. Return Value
  8222.      Returns SUCCESS or FAIL.  Function fails if the entries don't exist,
  8223.      if they are not the right type (person or group), or if the person was
  8224.      not a member of that group.
  8225.  
  8226.  
  8227. Remarks
  8228.      The record ID of the member is removed from the membership list of the
  8229.      group, and the record ID of the group is removed from the membership
  8230.      list of the member.  If the member is the last member of the group,
  8231.      the function also removes the group entry.
  8232.  
  8233.      This function uses the entry's record ID numbers to access the
  8234.      entries.  If only the names of the entries are known, the application
  8235.      can find the record IDs by using either PbGetEntry or
  8236.      PbFindFirstOrNext.
  8237.  
  8238.  
  8239.  
  8240.      NOTE:
  8241.           You must open the phonebook with PbOpenPhonebook before you can
  8242.           use this function.
  8243.  
  8244.  
  8245. See Also
  8246.      PbOpenPhonebook, PbRemoveEntry, PbGetEntry, PbFindFirstOrNext,
  8247.      PbFreePBE
  8248. 6-34                     PBLIB:  Library For Phonebook Management
  8249.  
  8250.  
  8251.  
  8252.  
  8253.  
  8254.                                                 PbRemoveFromGroup
  8255. Example Program
  8256.      The following program finds the requested person entry in the default
  8257.      phonebook and removes that person from the requested group.
  8258.  
  8259.      #include <stdio.h>
  8260.      #include <phonebk.h>
  8261.      #include <pberror.h>
  8262.      #include <pbglobal.h>
  8263.  
  8264.      char  *pbname = "c:\\connect\\default.pb";
  8265.  
  8266.      main()
  8267.      {
  8268.        PB  phonebook, *result;
  8269.        PBE *person, *group;
  8270.        int  rid = -1;
  8271.        char  aperson[32];
  8272.        char  agroup[32];
  8273.  
  8274.        if (result = PbOpenPhonebook(&phonebook,
  8275.                                     pbname))  {
  8276.          printf("Enter person removing from group - ");
  8277.          gets(aperson);
  8278.          printf("\nEnter group removing ");
  8279.          printf("person from - ");
  8280.          gets(agroup);
  8281.          if (person = PbGetEntry(&phonebook, NULL,
  8282.                             aperson, rid))  {
  8283.            if (group = PbGetEntry(&phonebook, NULL,
  8284.                             agroup, rid)) {
  8285.              if(PbRemoveFromGroup(&phonebook,group->id,
  8286.                              person->id))  {
  8287.                printf("Successfully removed %s from ");
  8288.                printf("%s\n", aperson, agroup);
  8289.                PbFreePBE(&phonebook, group);
  8290.              }
  8291.              else   {
  8292.                printf("\nError removing from group \n");
  8293.                printf("Message is %s \n",
  8294.                     PBerrlist[Pberrno]);
  8295.              }
  8296.            }
  8297.            else  {
  8298.              printf("\nError getting group \n");
  8299.              printf("Message is %s \n",
  8300.                     PBerrlist[Pberrno]);
  8301.            }
  8302.            PbFreePBE(&phonebook, person);
  8303.          }
  8304.          else {
  8305.            printf("\nError getting person \n");
  8306.            printf("Message is %s \n",
  8307.                   PBerrlist[Pberrno]);
  8308.          }
  8309.          fclose(phonebook.fp);
  8310.        }
  8311.        else       {
  8312.            printf("\nError opening phonebook \n");
  8313.            printf("Message is %s \n",
  8314. PBLIB:  Library For Phonebook Management                     6-35
  8315.  
  8316.  
  8317.  
  8318.  
  8319.  
  8320. PbRemoveFromGroup
  8321.                   PBerrlist[Pberrno]);
  8322.        }
  8323.      }
  8324.  
  8325.  
  8326.  
  8327.  
  8328.  
  8329.  
  8330.  
  8331.  
  8332.  
  8333.  
  8334.  
  8335.  
  8336.  
  8337.  
  8338.  
  8339.  
  8340.  
  8341.  
  8342.  
  8343.  
  8344.  
  8345.  
  8346.  
  8347.  
  8348.  
  8349.  
  8350.  
  8351.  
  8352.  
  8353.  
  8354.  
  8355.  
  8356.  
  8357.  
  8358.  
  8359.  
  8360.  
  8361.  
  8362.  
  8363.  
  8364.  
  8365.  
  8366.  
  8367.  
  8368.  
  8369.  
  8370.  
  8371.  
  8372.  
  8373.  
  8374.  
  8375.  
  8376.  
  8377.  
  8378.  
  8379.  
  8380. 6-36                     PBLIB:  Library For Phonebook Management
  8381.  
  8382.  
  8383.  
  8384.  
  8385.  
  8386.  
  8387.  
  8388.  
  8389.  
  8390.                  TOOLKIT COMPATIBILITY
  8391.  
  8392.           A  WITH TURBO C
  8393.  
  8394.                This appendix provides information on using Turbo C with the
  8395.                CAS and Phonebook Toolkit.
  8396.  
  8397.  
  8398.  
  8399.                NOTE:
  8400.                     Intel has tested the Toolkit using Microsoft C 5.1.
  8401.                     While the instructions below are provided for your
  8402.                     convenience, Intel has not fully tested the Toolkit
  8403.                     using Borland's Turbo C.
  8404.  
  8405.                Both the FAXLIB and PBLIB libraries were compiled using
  8406.                Microsoft C 5.1.  Code compiled under Microsoft C cannot be
  8407.                linked with TLINK, (Borland's Turbo Linker) because the
  8408.                Microsoft C compiler uses undocumented object record formats
  8409.                in the .OBJ files.  TLINK does not support these
  8410.                undocumented formats.
  8411.  
  8412.                To use the FAXLIB and PBLIB libraries with Turbo C,
  8413.                recompile the routines using the Turbo C compiler.
  8414.  
  8415.  
  8416.  
  8417.                NOTE:
  8418.                     The Microsoft C include file malloc.h is called alloc.h
  8419.                     in Turbo C.  Rename malloc.h to alloc.h in all the
  8420.                     source files before compiling.
  8421.  
  8422.                Rebuild the libraries using Borland's Turbo Librarian, TLIB.
  8423.  
  8424.                CASLIB links to applications using TLINK.  The object
  8425.                modules (.OBJ files) in the CASLIB library are built by
  8426.                Microsoft Macro Assembler 5.1.
  8427.  
  8428.  
  8429.  
  8430.  
  8431.  
  8432.  
  8433.  
  8434.  
  8435.  
  8436.  
  8437.  
  8438.  
  8439.  
  8440.  
  8441.  
  8442.  
  8443.  
  8444.  
  8445.  
  8446.           Toolkit Compatibility With Turbo C                            A-1
  8447.           A-1                            Toolkit Compatibility With Turbo C
  8448.  
  8449.